Customizing SMF > SMF Coding Discussion

How do i remove forced http from hyperlinks?

(1/3) > >>

GeofreyBiggins:
Hi,
i want to be able to use smf 2.0.2 as the basis of our intranet. so far it does everything i want apart from the hyperlink function.

It assumes you want HTTP which would be fine for the internet but i need to be able to link to internal network locations eg

P:\data\something

or


--- Code: ---P:\data\something\something.doc
--- End code ---

how can i get it to not force Http in front as when i try i end up with


--- Code: ---http://P:\data\something 
--- End code ---
which obviously doesn't work.

I found a thread that talks about making a change in sources/subs.php but it seems differnt to what i have so prob an older version as it was from 2008.

in my version i have


--- Code: ---// Parse any URLs.... have to get rid of the @ problems some things cause... stupid email addresses.
if (!isset($disabled['url']) && (strpos($data, '://') !== false || strpos($data, 'www.') !== false) && strpos($data, '[url') === false)
{
// Switch out quotes really quick because they can cause problems.
$data = strtr($data, array('&#039;' => '\'', '&nbsp;' => $context['utf8'] ? "\xC2\xA0" : "\xA0", '&quot;' => '>">', '"' => '<"<', '&lt;' => '<lt<'));

// Only do this if the preg survives.
if (is_string($result = preg_replace(array(
'~(?<=[\s>\.(;\'"]|^)((?:http|https)://[\w\-_%@:|]+(?:\.[\w\-_%]+)*(?::\d+)?(?:/[\w\-_\~%\.@!,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i',
'~(?<=[\s>\.(;\'"]|^)((?:ftp|ftps)://[\w\-_%@:|]+(?:\.[\w\-_%]+)*(?::\d+)?(?:/[\w\-_\~%\.@,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i',
'~(?<=[\s>(\'<]|^)(www(?:\.[\w\-_]+)+(?::\d+)?(?:/[\w\-_\~%\.@!,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i'
), array(
'[url]$1[/url]',
'[ftp]$1[/ftp]',
'[url=http://$1]$1[/url]'
), $data)))
$data = $result;

$data = strtr($data, array('\'' => '&#039;', $context['utf8'] ? "\xC2\xA0" : "\xA0" => '&nbsp;', '>">' => '&quot;', '<"<' => '"', '<lt<' => '&lt;'));
}

--- End code ---

I have tried adding in P:\ as an extra line but it doesn't seem to work.

Does anyone know how to do this and even if i am in the right area.

thansk

K@:
Hi, Geofrey!



Is this when you click on the "Insert hyperlink" icon?

Because, you don't have to use that (I rarely do). You can simply paste the URL.

Although, when I use the icon, it just gives me [url][/url] tags and doesn't force the "http" thing, at all.

I can just do P:\data\something without any hassles.

Or, am I on the wrong track, here?

Sorck:
It might be easier to add a [file] BBCode as you need to use the 'file' protocol rather than http for your link.

SMF gets a bit confused by a file link for Windows as you end up with two colons:

--- Code: ---file://C:/Users/admin/Documents/my/file.docx
--- End code ---

You might have to link like this though: [file]C:\Users\me\my\path\file.odf[/file] or [file]/home/me/my/path/file.odf[/file]. The REGEX would have to cope for the UNIX and Windows ways of linking so it could confuse things. :P I'm not sure on the REGEX needed to verify if it's a valid link or not.


--- Quote from: K@ on August 22, 2012, 08:12:24 AM ---Hi, Geofrey!



Is this when you click on the "Insert hyperlink" icon?

Because, you don't have to use that (I rarely do). You can simply paste the URL.

Although, when I use the icon, it just gives me [url][/url] tags and doesn't force the "http" thing, at all.

I can just do P:\data\something without any hassles.

Or, am I on the wrong track, here?

--- End quote ---
That still hyperlinks it K@ - this wants to use the file:// protocol rather than http:// I think due to it trying to link to the local/network filesystem.

It might be better to just share everything on your intranet by ftp:// or http:// rather than linking to the local filesystem.

GeofreyBiggins:
wow thanks for the quick response.

maybe i have my thinking wrong but i want users to be able to click the insert hyperlink and then put in the network address so that it becomes a live link.

When i use the link button it gives me the [url] tags but when i submit it automatically adds the http to the link.

you are correct that they can just write the network address but it has no link so users would have to copy and paste that into windows explorer rather than being able to just click.

my boss is sure to say 'but i just want to be able to click on a link... >:('


thanks

GeofreyBiggins:
ah cool, how do i add BBcode?

Navigation

[0] Message Index

[#] Next page

Go to full version