![]() |
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"'; Code:
$checked['parseurl'] = ($postinfo['parseurl']) ? 'checked="checked"' : ''; In /private.php find this: Code:
if ($vbulletin->GPC['parseurl']) Code:
if ($vbulletin->GPC['parseurl'] OR stristr($vbulletin->GPC['message'], $_SERVER['HTTP_HOST'])) ALSO In /private.php find this: Code:
'parseurl' => true, Code:
'parseurl' => false, In /profile.php find this: Code:
$signature = convert_url_to_bbcode($signature); Code:
if (stristr($signature, $_SERVER['HTTP_HOST'])) In /usernote.php find this: Code:
if ($vbulletin->GPC['parseurl']) 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']) Code:
if ($this->info['parseurl'] OR stristr($pagetext, $_SERVER['HTTP_HOST'])) |
screen please :)
|
Screen shot of what, Allen?
There's nothing to take a picture of. |
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. |
A maybe easier, generalized and more failsafe approach:
In functions_newpost.php FIND PHP Code:
PHP Code:
PHP Code:
PHP Code:
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. |
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. |
Hmm, before I posted this snippet I tested it on localhost and it seemed to work just fine.
|
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:
line 1922-1938 of class_bbcode.php PHP Code:
:D I believe we need to play with the 'function parse_wysiwyg_anchor'. |
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. |
I have played with it and had some success ..... so let me continue.
I bet I can get this one, Kirby!! |
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:
PHP Code:
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 |
Hmm, for me WYSIWYG works without the additional modifications.
I just typed (in WYSIWYG, autoaprse was checked) Code:
http://www.foobar.com 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. |
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). |
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. |
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. |
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. |
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: |
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. |
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. |
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?
|
Quote:
I thought it was just the cookie from previous site and next site going to after leaving. In other words I open browser to say msn.com Now I open my site's bookmark Now I come here to vb.org Now I close browser I thought msn would see my site's cookie (and theirs). And vb.org would see my site's cookie (and theirs). And my site would see all 3. Or would all 3 sites see all 1001 (j/k) cookies that reside on my pc?? :eyepopping: If it's just the "2 or 3" referencing cookies which get passed, then my method works .... as long as my members abide by the "open new browser and obviously not on our website before pasting the link" clause which my members made for themselves. If not .... then what the F am I making this for and why in the H was I told differently by my site's members what's the GD point of not posting links when it just don't matter. :D:banana::D I said all that with a big smile .... not sour grapes. |
Quote:
Cookies are bound to Domains. There is no way (except buggy Browsers) they can be send to other Domains then those which set them. |
Anybody get this to work on 3.5.2?
Doesn't work at all on it |
No, it doesn't work.
This needs a major makeover. And unfortunately I don't know when I'll have time to do so. I have a lot of other things going on in my life right now. I do apologize. I'll send you a PM when I get to it. |
Thanks for your response. I have used the mod or a type of it for ages. It is a shame that it can't be shut off in 3.5.2. Your hard work is appreciated. I think at this point I'm going back to 3.0.7.
Thanks. |
All times are GMT. The time now is 04:43 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|