[ABD] Own links own the window + vbulletin short urls

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.
niekas
Registered User
Posts: 562
Joined: Sun Sep 23, 2001 7:34 am

[ABD] Own links own the window + vbulletin short urls

Post by niekas »

Just few quick fixups that you might find helpful.. You should install this mod If you prefer that same domain links should open in the same window/tab. Any other link will still open in new tab/window. I added Cobra85 vbulletin style short url mod (with a little bug fix). No more messed up wide posts because somebody posted a URL with SID to ebay or amazon. As you can see both mods compliment each other.

Code: Select all

##############################################################
## MOD Title: Own links own the window
## MOD Author: niekas < dont.email.me_use.pm_on.phpbb@hotmail.com > (niekas)  
## MOD Description: This mod will change link behavior in viewtopic.
##Links to the same domain will open in the same tab/window instead of
##forcing new one. Other than your phpBB instalation domains and subdomains will open in new tabs/windows
## MOD Version: 0.1.1
##
## Installation Level: Easy
## Installation Time: 5 Minutes
## Files To Edit: 1
## bbcode.php
##
## Included Files: (n/a)
##############################################################
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
############################################################## ## Author Notes: 
## I'm adding improved short vbulletin style url mod from Cobra85 
## http://www.phpbb.com/phpBB/viewtopic.php?t=131079 
##############################################################
## MOD History:
##
##   2004-10-24 - Version 0.1.0
##      - First Public Beta
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ OPEN ]------------------------------------------
#

bbcode.php

#
#-----[ FIND ]------------------------------------------
#

function make_clickable($text)
{
#
#-----[ BEFORE, ADD ]------------------------------------------
#


function soft_hyphen($text, $max, $char = "­")
{
$words = explode(' ', $text);
   foreach($words as $key => $word)
   {
       $length = strlen($word);
       if($length > $max)
           $word = chunk_split($word, floor($length/ceil($length/$max)), $char);
       $words[$key] = $word;
   }
   return implode(' ', $words);
}

#
#-----[ AFTER, ADD ]------------------------------------------
#

global $board_config;

#
#-----[ FIND ]------------------------------------------
#

return($ret);

#
#-----[ BEFORE, ADD ]------------------------------------------
#

  $ret = preg_replace("/<a href=(.*?)>(.*?)<\/a>/ie", "(strlen(\"\\2\") > 65 && (!eregi(\"<\", \"\\2\") && !strpos( \"\\2\", \" \") )) ? '<a href='.stripslashes(\"\\1\").'>'.substr(\"\\2\", 0, 42) . '...' . substr(\"\\2\", -10).'</a>' : '<a href='.stripslashes(\"\\1\").'>'.soft_hyphen(stripslashes(\"\\2\"),120).'</a>'", $ret);


	$ret = preg_replace("/<a href=(\"http:\/\/www\.".$board_config['server_name'].".*?|\"http:\/\/".$board_config['server_name'].".*?)>(.*?)<\/a>/ie", "'<a href=' .(str_replace(' target=\"_blank\"','', stripslashes(\"\\1\"))).'>'.stripslashes(\"\\2\").'</a>'", $ret);



#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM 

Last edited by niekas on Mon Dec 06, 2004 6:45 am, edited 3 times in total.
»»EDDY««
Registered User
Posts: 220
Joined: Mon Jun 02, 2003 10:14 am
Location: Poland/Slupsk
Contact:

Post by »»EDDY«« »

Works good:)


EDIT:
Not good... this MOD + Posted email js they conflict.

Code: Select all

');document.write('eddy');document.writ...t.write('
Make a Tiny URL in excellent domain heh.pl


cooling system & water cooling
User avatar
onigumo
Registered User
Posts: 1755
Joined: Fri Oct 31, 2003 2:32 am
Contact:

Post by onigumo »

Great MOD. I'll keep an eye on its development.
I write articles on community building
@ The Infinity Program.
msie
Registered User
Posts: 15
Joined: Mon Oct 04, 2004 5:42 am

Post by msie »

nice, i like this.
niekas
Registered User
Posts: 562
Joined: Sun Sep 23, 2001 7:34 am

Post by niekas »

»»EDDY«« wrote: Works good:)


EDIT:
Not good... this MOD + Posted email js they conflict.

Code: Select all

');document.write('eddy');document.writ...t.write('


Replace

Code: Select all

	   $ret = preg_replace("/<a href=(.*?)>(.*?)<\/a>/ie", "(strlen(\"\\2\") > 65 && !eregi(\"<\", \"\\2\") ) ? '<a href='.stripslashes(\"\\1\").'>'.substr(\"\\2\", 0, 42) . '...' . substr(\"\\2\", -10).'</a>' : '<a href='.stripslashes(\"\\1\").'>'.stripslashes(\"\\2\").'</a>'", $ret); //all credits goes to Cobra85 - i just fixed a little bug with slashes 
with

Code: Select all

   $ret = preg_replace("/<a href=(\"http.*?)>(.*?)<\/a>/ie", "(strlen(\"\\2\") > 65 && !eregi(\"<\", \"\\2\") ) ? '<a href='.stripslashes(\"\\1\").'>'.substr(\"\\2\", 0, 42) . '...' . substr(\"\\2\", -10).'</a>' : '<a href='.stripslashes(\"\\1\").'>'.stripslashes(\"\\2\").'</a>'", $ret); //all credits goes to Cobra85 - i just fixed a little bug with slashes 
It will only shorten links that start with http, https and leave javscript email links intact
»»EDDY««
Registered User
Posts: 220
Joined: Mon Jun 02, 2003 10:14 am
Location: Poland/Slupsk
Contact:

Post by »»EDDY«« »

Doesn't work.
Make a Tiny URL in excellent domain heh.pl


cooling system & water cooling
niekas
Registered User
Posts: 562
Joined: Sun Sep 23, 2001 7:34 am

Post by niekas »

»»EDDY«« wrote: Doesn't work.


can you provide details? I don't have your conflicting mod installed. :roll: :lol:
»»EDDY««
Registered User
Posts: 220
Joined: Mon Jun 02, 2003 10:14 am
Location: Poland/Slupsk
Contact:

Post by »»EDDY«« »

MOD at all doesn't work after change of code.
Make a Tiny URL in excellent domain heh.pl


cooling system & water cooling
niekas
Registered User
Posts: 562
Joined: Sun Sep 23, 2001 7:34 am

Post by niekas »

»»EDDY«« wrote: MOD at all doesn't work after change of code.


My mod is working fine with regular phpbb - its your other mods that are conflicting with it. I'm not a psychic and i do not plan to install all your mods so i could offer you personalized support. How do i know that you didn't make some other mistakes?

"Mod doesn't work" is not constructive feedback. Try again
niekas
Registered User
Posts: 562
Joined: Sun Sep 23, 2001 7:34 am

Post by niekas »

0.1.1 version updated: will work correctly with linked chunks of text and long strings/urls inside of linked text.
MrDSL
Registered User
Posts: 283
Joined: Thu Jul 15, 2004 1:52 am
Contact:

Post by MrDSL »

I get a parse error

Parse error: parse error, unexpected T_STRING in /includes/bbcode.php on line 692



that line is

Code: Select all

   $ret = preg_replace("/<a href=("http://www.".$board_config['server_name'].".*?|"http://".$board_config['server_name'].".*?)>(.*?)</a>/ie", "'<a href=' .(str_replace(' target="_blank"','', stripslashes("1"))).'>'.stripslashes("2").'</a>'", $ret); 
niekas
Registered User
Posts: 562
Joined: Sun Sep 23, 2001 7:34 am

Post by niekas »

MrDSL,

i fixed it - somehow phpbb.com stripped double slashes from old code while editing.
MrDSL
Registered User
Posts: 283
Joined: Thu Jul 15, 2004 1:52 am
Contact:

Post by MrDSL »

Its works now thanks.

Been looking for a mod that does this good job :)
Cross_+_Flame
Registered User
Posts: 295
Joined: Wed Oct 30, 2002 3:37 pm
Location: Okie-homa!
Contact:

Post by Cross_+_Flame »

My members have the following problem. Whenever they post a text-link

Code: Select all

[url=http://www.google.com]Google is the bestest bestest bestest ever browser and you should use it all the time[/url]
It also gets shrunk to:

Google is the bestest beste...time (or something similar).

Is there a way to have it affect only links that begin with http:// so that my text links don't get shortened?

Otherwise, great mod and thank you.
Cross_+_Flame
Registered User
Posts: 295
Joined: Wed Oct 30, 2002 3:37 pm
Location: Okie-homa!
Contact:

Post by Cross_+_Flame »

nevermind

I had installed an earlier version, and then I noticed you updated it Dec 4th. That fixed the problem.

Thanks :D
Locked

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