[BETA] External Link MOD

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
ShadowTek
Registered User
Posts: 66
Joined: Thu Jul 22, 2004 8:21 am
Contact:

Post by ShadowTek »

Yeah!! It works :)

Thanks for all the help, outstaning MOD :D

ShadowTek
kkroo
Registered User
Posts: 729
Joined: Sat Dec 03, 2005 4:49 pm
Contact:

Post by kkroo »

Thanks! The reason why I didn't want to fix it so that an internal link doesn't get a link.php extension is because then it would only resolve the problem for internal links but no external ones.

Well i am glad to here that it is running fine with you and you enjoy it!
My MODs

Need a coder?

Enjoy my Mods? - Image
kkroo
Registered User
Posts: 729
Joined: Sat Dec 03, 2005 4:49 pm
Contact:

Post by kkroo »

Thanks a lot kulinar and ShadowTek for pointing out that bug! upgraded to 1.2.2 with the bug fixed :D

If you guys find any more, point them out!
My MODs

Need a coder?

Enjoy my Mods? - Image
Serj21
Registered User
Posts: 137
Joined: Thu Apr 15, 2004 6:23 pm
Contact:

Post by Serj21 »

Just a suggestion.

Currently in your mod if the site: abcd.sitename.com is in the database and opened it won't open in the frame and just open it in page like normal. This is great.

Next if the same url aBCd.sitename.com is opened it gets opened in a frame. Notice same URL but just uppercase letters in it.

Wouldn't it be better that abcd link openes same as ABCD link otherwise your going to have to have a database full of every combonation of the urls esp if your users tend to use different urls?

Does it also allow wildcards? Say for example *.sitename.com to allow all subdomains at sitename.com ??

Just my suggestions so far. Good mod btw. I started writing one last week and then noticed today you have stolen my idea ;) lol jk your is much more than I was going to do, my was just a private mod.
Serj
kkroo
Registered User
Posts: 729
Joined: Sat Dec 03, 2005 4:49 pm
Contact:

Post by kkroo »

Thanks for the ideas Serj21, they are good ones. I will try to do them later on.
My MODs

Need a coder?

Enjoy my Mods? - Image
calafat
Registered User
Posts: 7
Joined: Mon Apr 11, 2005 7:53 pm
Location: Zaragoza (Spain)
Contact:

Post by calafat »



Hello.

I've installed the 1.2.2 version and i have the same problem

http://www.jaquearagon.com/phpbb/link.' ... /kb/908519

Please, I need help :oops:
kkroo
Registered User
Posts: 729
Joined: Sat Dec 03, 2005 4:49 pm
Contact:

Post by kkroo »

ok...

do this:
in bbcode.php

Find:

function make_clickable($text)
{

After add:

global $phpbb_root_path, $phpEx;


Find:


function prepare_bbcode_template($bbcode_tpl)
{

After add:

global $phpbb_root_path, $phpEx;
Last edited by kkroo on Tue Jan 31, 2006 6:26 am, edited 1 time in total.
My MODs

Need a coder?

Enjoy my Mods? - Image
calafat
Registered User
Posts: 7
Joined: Mon Apr 11, 2005 7:53 pm
Location: Zaragoza (Spain)
Contact:

Post by calafat »

Don´t work!

I have the same result.

Thanks for your interest.
kkroo
Registered User
Posts: 729
Joined: Sat Dec 03, 2005 4:49 pm
Contact:

Post by kkroo »

this is what works for me:

FIND

// We do URLs in several different ways..
$bbcode_tpl['url1'] = str_replace('{URL}', '\\1', $bbcode_tpl['url']);
$bbcode_tpl['url1'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url1']);

$bbcode_tpl['url2'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
$bbcode_tpl['url2'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url2']);

$bbcode_tpl['url3'] = str_replace('{URL}', '\\1', $bbcode_tpl['url']);
$bbcode_tpl['url3'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['url3']);


REPLACE WITH

// We do URLs in several different ways..
$bbcode_tpl['url1'] = str_replace('{URL}', 'link.'.$phpEx.'?url=\\1', $bbcode_tpl['url']);
$bbcode_tpl['url1'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url1']);

$bbcode_tpl['url2'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
$bbcode_tpl['url2'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url2']);

$bbcode_tpl['url3'] = str_replace('{URL}', 'link.'.$phpEx.'?url=\\1', $bbcode_tpl['url']);
$bbcode_tpl['url3'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['url3']);


FIND

// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, comma, double quote or <
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);

// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// zzzz is optional.. will contain everything up to the first space, newline,
// comma, double quote or <.
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);


REPLACE WITH

// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, comma, double quote or <
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"link.{$phpEx}?url=\\2\" target=\"_blank\">\\2</a>", $ret);

// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// zzzz is optional.. will contain everything up to the first space, newline,
// comma, double quote or <.
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"link.{$phpEx}?url=http://\\2\" target=\"_blank\">\\2</a>", $ret);


And you have to do what i told you to do in the previous post
My MODs

Need a coder?

Enjoy my Mods? - Image
calafat
Registered User
Posts: 7
Joined: Mon Apr 11, 2005 7:53 pm
Location: Zaragoza (Spain)
Contact:

Post by calafat »

I've copied exactly your code in my bbcode.php file and now i have another error:

http://www.jaquearagon.com/phpbb/link.? ... /kb/908519

:oops:
kkroo
Registered User
Posts: 729
Joined: Sat Dec 03, 2005 4:49 pm
Contact:

Post by kkroo »

that is because you didn't do this: http://www.phpbb.com/phpBB/viewtopic.ph ... 30#1978730
My MODs

Need a coder?

Enjoy my Mods? - Image
calafat
Registered User
Posts: 7
Joined: Mon Apr 11, 2005 7:53 pm
Location: Zaragoza (Spain)
Contact:

Post by calafat »

Ok.

Sorry. :oops:

Now, it works! :lol:

Thanks for all!
kkroo
Registered User
Posts: 729
Joined: Sat Dec 03, 2005 4:49 pm
Contact:

Post by kkroo »

Version 1.3 released!

Fixed a bug from version 1.2.2 and added a new feture that
allows wild cards and supports https, www and different cases and i made it easier
to manage in the admin panel.

To download, see first post!
My MODs

Need a coder?

Enjoy my Mods? - Image
Serj21
Registered User
Posts: 137
Joined: Thu Apr 15, 2004 6:23 pm
Contact:

Post by Serj21 »

kkroo wrote: Version 1.3 released!

Fixed a bug from version 1.2.2 and added a new feture that
allows wild cards and supports https, www and different cases and i made it easier
to manage in the admin panel.

To download, see first post!


Any chance you can produce a change log from old version and this version?
Cant see where the wild card part is added or if it works fine.

Thanks, Serj
kkroo
Registered User
Posts: 729
Joined: Sat Dec 03, 2005 4:49 pm
Contact:

Post by kkroo »

I am sorry, i didn't create one while i was coding, it is just that i deleted so much crap and put in a lot more so it is really hard for me to know what exactly i did. I just played around with stuff until it works the way i need it to work. But i can tell you the part for wildcards:

Code: Select all

function is_allowed_host($link_url, $allowed_hosts)
{
	preg_match('/^(?:https?:\/\/)?(?:www\.)?(.+?)(?:\/|$)/i', $link_url, $link_host);
   $link_host = strtolower($link_host[1]);
   foreach ( $allowed_hosts as $host )
   {
      $host = '|^'.str_replace('\*','[A-Z0-9\-.]*?',preg_quote($host,'|')).'$|i';
 if ( preg_match($host,$link_host) ) return TRUE;
   }
   return FALSE;
}
I hope that helps.
My MODs

Need a coder?

Enjoy my Mods? - Image
Post Reply

Return to “[2.0.x] MODs in Development”