News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Titled Links

Started by Mick., July 14, 2007, 12:18:47 PM

Previous topic - Next topic

qubbah

what is the different between this mod with show the local url. tq

Mick.

I looked at that mod and my first thought is that, local urls. No external ones.

Biology Forums

Is there any other method to accomplish this without the extensive coding?

Arantor


Biology Forums

Just tested this mod on a fresh install of 1.1.19 and it doesn't work.

Biology Forums

One problem I have with this is that it converts all links. I believe that if links are embedded in [url][/url], it should show the link URL instead of the title.

spiros

Just tested and it says not compatible with 2.0.15.

lurkalot

Quote from: spiros on March 31, 2019, 08:47:21 AM
Just tested and it says not compatible with 2.0.15.

Yes the install says, <install for="2.0 RC3">

shadav

this doesn't seem to work  :(

2.0.15

installed emulating  2.0 RC4
went to post settings and clicked the box for Convert links to titled URL's and left the setting at 0 for Maximum URLs to title

i've tested posting links but they don't convert

I uploaded convert_urls.php and tried to run it but getting a 500 error


Mick.

@shadav This mod is very old.

In Sources/Subs-Post.php find:



// Time to do some cool stuff with URL's
if (!$previewing && $modSettings['convert_urls'])
{

// We're gonna save the old socket timeout, reduce it down to 3 seconds, so we prevent this from hanging up
// We are supressing the errors in case the user cannot change this value on their server.
$timeout = ini_get('default_socket_timeout');
@ini_set('default_socket_timeout',3);

$message = preg_replace(array('~(?<=[\s>\.(;\'"]|^)((?:http)://[\w\-_%@:|]+(?:\.[\w\-_%]+)*(?::\d+)?(?:/[\w\-_\~%\.@,\?&;=#+:\'\\\\]*|[\(\{][\w\-_\~%\.@,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i', '~(?<=[\s>(\'<]|^)(www(?:\.[\w\-_]+)+(?::\d+)?(?:/[\w\-_\~%\.@,\?&;=#+:\'\\\\]*|[\(\{][\w\-_\~%\.@,\?&;=#(){}+:\'\\\\]*)*[/\w\-_\~%@\?;=#}\\\\])~i'), array('[url]$1[/url%]', '[url]$1[/url%]'), $message);

// Now we find the urls that we just changed, so we can run through them and get titles
preg_match_all("~\[url\](.+?)\[/url%\]~smi", $message, $urls);

if (!empty($urls[0]))
{

// Lets make a counter so we don't exceed the settings...
$title_counter = 0;
foreach($urls[1] as $uri)
{
// If our counter has exceeded the amount, replace the remaining urls back to what they were and get outta dodge.
if(!empty($modSettings['title_url_count']) && $title_counter++ >= $modSettings['title_url_count'])
{
$message = preg_replace('~\[url\]' . $uri . '\[/url%\]~', $uri, $message);
continue;
}

// Attach http:// to the url...
$uri_modified = strpos($uri, 'http://') === false ? 'http://' . $uri : $uri;

// Use the @ to suppress errors from the function not finding a url, which will still return false if
// there is an error.  This just prevents the error log from filling up without cause.
// In 2.0, we have fetch_web_data() which makes our lives easier :)
require_once($sourcedir . '/Subs-Package.php');
$request = @fetch_web_data($uri_modified);

if ($request !== false && preg_match('~<title>(.+?)</title>~smi', $request, $matches))
{
$title = $smcFunc['htmlspecialchars'](stripslashes($matches[1]), ENT_QUOTES);
// Need to fix the &amp;amp;
$title = str_replace('&amp;amp;', '&amp;', $title);
// w00t!  Changin the link to titlize it (is that word?)
$message = str_replace('[url]' . $uri . '[/url%]', '[url=' . $uri_modified . ']' . $title . '[/url]', $message);
}

// Looks like we couldn't get the title, darn.  Back to the original we go...
else
$message = str_replace('[url]' . $uri . '[/url%]', $uri, $message);
}
}
// Change it back to what it was.  Suppress again incase...
@ini_set('default_socket_timeout',$timeout);
}


There are 3 instances of http. Change it to https. I will update the package when i can. Ty.

1.1Nerd

Hello, the package for this mod seems to be broken. It is not a compressed but bare php file. Could you please reupload it? Thank you!

Mick.

Quote from: 1.1Nerd on September 03, 2020, 10:19:01 PM
Hello, the package for this mod seems to be broken. It is not a compressed but bare php file. Could you please reupload it? Thank you!
Not sure why it was missing. Try again.

1.1Nerd

Hello Mick, thank you. The package download now worked but the current package no longer seems to be supporting the SMF 1.1 branch - I wanted to use that package on my old 1.1 Board. Could you please kindly provide the 1.2 (?) version wich still support the 1.1 branch. Thank you!

spiros

I tried the latest version of the mod but when I modify a post and paste a forum topic URL and then click save nothing happens. Also, I cannot find anywhere on admin panel its settings.

I also tried the convert_urls script on SMF 2.0.17 and it gives HTTP ERROR 500

alexetgus

Hi!

Oooooh! That's a very good idea! :)
I'll test it quickly ;)


EDIT :
Why don't you use the SSI.php file for the script convert_urls.php? You'd avoid a lot of trouble.



alexetgus

#235
I have just tested very quickly and I already have one or two questions:

- The mod doesn't follow redirections?! (Example : No WWW to WWW, HTTP to HTTPS)
- I have the impression that the mod only follows HTTPS links, am i right?
- A BBCode tag (any one) prevents the title on the link, not just the URL & IURL tags. It's a pity.

- Exceptions should be added, for localhost for example... ;)


EDIT

The file convert_urls.php is obsolete for PHP 7.x...
Use SSI.php and the SMF functions for fix the problem!

spiros

Quote from: alexetgus on September 05, 2020, 07:13:29 AM
EDIT :
Why don't you use the SSI.php file for the script convert_urls.php? You'd avoid a lot of trouble.

Hi, not sure how that can be done. Sorry, not a coder :)

alexetgus

Ah! Indeed.
Too bad, it's a real shame.

Yet SSI.php is easy to use, it's as if you were on SMF in an external page.
Look here : https://wiki.simplemachines.org/smf/Category:SSI

If you were using SSI.php, your convert_urls.php file would be usable.

spiros

Quote from: spiros on September 05, 2020, 09:47:42 AM
Sorry, not a coder :)

Quote from: alexetgus on September 05, 2020, 09:55:43 AM
If you were using SSI.php, your convert_urls.php file would be usable.

Looks like this needs coding to me :)

alexetgus

Okay, i'll shut up... :-X

And yet, you have created a mod, you the non-coder... :-\

But! :-X :-X :-X

Advertisement: