Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Extended auto-linker (adds ed2k and sip link recognition) Details »»
Extended auto-linker (adds ed2k and sip link recognition)
Version: 0.2, by The M.I.P. The M.I.P. is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Version: 3.5.1 Rating:
Released: 11-02-2005 Last Update: Never Installs: 12
Uses Plugins
Is in Beta Stage  
No support by the author.

Extended auto-linker 0.2
20051003 by mip

This plugin extends the auto-parse url option to recognize ed2k and sip (VoIP) links correctly.
ed2k file links are pretty-printed with the file name and a human-readable file size.

INSTALLATION:
Upload and activate plugin as usual.
If you want to automatically include a tag in a parsed ed2k link, you should uncomment line 67 (// $filenametag = ...) and set your desired tag.

NOTES:
This plugin uses (among other things) a slightly modified regex which allows "|" characters inside all auto-recognized URLs as required for ed2k links.

SCREENSHOTS:

Writing a post containing some ed2k and sip URIs. Auto-parse URL option must be on.


Preview of posting with recognized URLs.
Note the formatting of ed2k file urls with the human readable size.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 11-03-2005, 07:15 PM
Snake's Avatar
Snake Snake is offline
 
Join Date: Mar 2005
Location: Cleveland, OH
Posts: 3,832
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

First one to install, thank you!
Reply With Quote
  #3  
Old 11-07-2005, 07:47 AM
MioTraGusa's Avatar
MioTraGusa MioTraGusa is offline
 
Join Date: Oct 2005
Location: Espa?a
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

God job, but if the ed2k link contain [ ] don?t work correctly :surprised:

is a minor bug, but it is possible to be solved?

tanks for the modification *installed
Reply With Quote
  #4  
Old 11-07-2005, 08:52 PM
Sovereign Sovereign is offline
 
Join Date: Apr 2004
Posts: 182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Didn't EDonkey shut down because of fileswapping? Does this technology now have a legal use then?
Reply With Quote
  #5  
Old 11-08-2005, 05:16 PM
MioTraGusa's Avatar
MioTraGusa MioTraGusa is offline
 
Join Date: Oct 2005
Location: Espa?a
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Legal_controversy

Quote:
Under US law, "the Betamax decision" case holds that copying "technologies" are not inherently illegal, if substantial non-infringing use can be made of them. This decision, predating the widespread use of the Internet applies to most data networks, including peer-to-peer networks, since distribution of correctly licensed files can be performed. These non-infringing uses include sending open source software, public domain files and out of copyright works. Other jurisdictions tend to view the situation in somewhat similar ways.
legal or not legal? that is the question:ninja:
Reply With Quote
  #6  
Old 11-22-2005, 03:49 PM
Mastar's Avatar
Mastar Mastar is offline
 
Join Date: Sep 2005
Posts: 680
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are they any options/settings for this?
Reply With Quote
  #7  
Old 12-02-2005, 09:30 AM
MRGTB MRGTB is offline
 
Join Date: Dec 2004
Posts: 548
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Any chance you can port this over as a vB 3.0 hack?
Reply With Quote
  #8  
Old 12-27-2005, 01:01 AM
MRGTB MRGTB is offline
 
Join Date: Dec 2004
Posts: 548
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I see this is still in the Beta stages. I hope you fix the square brackets "[]" problem as this hack is very promising.

I also think the option to add your own tag is a great idea, very cool indeed and that gives you the ability to advertise your site in the tag in links.

I have one sugestion though. Make the ed2k links so they open in the same browser window instead of a new browser window. By doing that you won't have to close a new browser window everytime to add a link from the board.

Also take a look here at this same ed2k code created for phpbb for some extra ideas that might prove useful. This hack has come a long way and is the best ed2k hack out there. I'm sure there is stuff in this below you can use.

Code:
############################################################## 
## MOD Title: eD2k Links add all Feature 
## MOD Author: Simon Moon <simon@gomp.net> (Christian Riesen) http://www.blackpearltech.com/ 
## MOD Authors: [ Oki/Mozes/Meithar/ppw ] 
## 
## MOD Description: Makes ed2k links for files and servers clickable and adds a link for adding all files in a post at once. 
## MOD Version: 1.2.0 
## 
## Installation Level: moderate 
## Installation Time: 6 Minutes 
## Files To Edit: 2 
##               includes/bbcode.php 
##               viewtopic.php 
## Included Files: images/mule_icon.gif (http://www.ed2k-it.com/forum/images/mule_icon.gif) 
##                              images/ed2k-info.gif (http://www.ed2k-it.com/forum/images/ed2k-info.gif) 
## 
## Tested with phpBB Version 2.0.11 to 2.0.15 
## Forum Link: http://www.phpbb.com/phpBB/viewtopic.php?t=206016 
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/downloads/ 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/downloads/ 
############################################################## 
## Author Notes: 
## If you have already installed a ed2k hack (which you mostlikely will have) 
## check the files mentioned below anyways and change it to this version of 
## the hack. This is very important to ensure it will work properly, otherwise 
## you might have weird problems. 
## Change the line below that looks like this to have a different text: 
## $t_ed2kinsert .= "<a href='javascript:addall()'>Add ".$t_ed2k_confirmed." links to ed2k client</a> "; 
## You can for example leave away the number of files. 
############################################################## 
## MOD History: 
##    2005-05-07 - Version 1.2.0 
##       - compatible with latest ed2k link formats 
##      - friendly readable names, kB, MB 
##      - added icons 
## 
##   2004-06-27 - Version 1.1.1 
##      - Error with ' sign in filenames 
## 
##   2004-06-27 - Version 1.1.0 
##      - Javascript bug in add all, predefining of filearray 
## 
##   2004-06-27 - Version 1.0.0 
##      - First release, works fine, could use some different look 
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 
# 
#-----[ OPEN ]----------------------------------------------- 
# 

includes/bbcode.php 

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

$bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url4']); 

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

// ed2k links 
$bbcode_tpl['url5'] = str_replace('{URL}', '\\1', $bbcode_tpl['url']); 
$bbcode_tpl['url5'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['url5']); 

// ed2k links with description 
$bbcode_tpl['url6'] = str_replace('{URL}', '\\1', $bbcode_tpl['url']); 
$bbcode_tpl['url6'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url6']); 
// end ed2k links 

# 
#-----[ FIND ]----------------------------------------------- 
# 
  
// phpBB code.. (no xxxx:// prefix). 
$patterns[] = "#\[url=((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is"; 
$replacements[] = $bbcode_tpl['url4']; 

# 
#-----[ AFTER, ADD ]----------------------------------------------- 
# 
  
// url-ed2k, name code 
$patterns[] = "#\[url=(ed2k://\|file\|.*\|\d+\|\w+\|/?)\](.*?)\[/url\]#si"; 
$replacements[] = $bbcode_tpl['url5']; 

// name code 
$patterns[] = "#\[url=(ed2k:(//)?\|server\|[\d\.]+\|\d+\|/?)\](.*?)\[/url\]#si"; 
$replacements[] = $bbcode_tpl['url6']; 
// end url-ed2k 

# 
#-----[ FIND ]----------------------------------------------- 
# 
  
/** 
 * Rewritten by Nathan Codding - Feb 6, 2001. 
 * - Goes through the given string, and replaces xxxx://yyyy with an HTML <a> tag linking 
 *    to that URL 

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

// ed2k links 
// Returns a file size formatted in a more human-friendly format, rounded 
// to the nearest Gb, Mb, Kb, or byte. 

function ed2k_humanize_size ($size, $rounder = 0, $min = '') 
{ 
   $sizes   = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); 
   $rounders = array(0,   0,    0,    2,    2,    3,    3,    3,    3); 
   $ext = $sizes[0]; 
   $rnd = $rounders[0]; 

   if ($min == 'KB' && $size < 1024) 
   { 
      $size = $size / 1024; 
      $ext = 'KB'; 
      $rounder = 1; 
   } 
   else 
   { 
      for ($i=1, $cnt=count($sizes); ($i < $cnt && $size >= 1024); $i++) 
      { 
         $size = $size / 1024; 
         $ext  = $sizes[$i]; 
         $rnd  = $rounders[$i]; 
      } 
   } 

   if (!$rounder) 
   { 
      $rounder = $rnd; 
   } 

   return round($size, $rounder) . '&nbsp;' . $ext; 
} 

function ed2k_link_callback ($m) 
{ 
   $max_len = 120; 
   $href = 'href="' . $m[2] . '" class="postlink"'; 
   $size = ed2k_humanize_size($m[4]); 
   $fname = urldecode($m[3]); 

   if (strlen($fname) > $max_len) 
   { 
      $fname = substr($fname, 0, $max_len - 19) . '...' . substr($fname, -16); 
   } 
   if (preg_match('#[<>"]#', $fname)) 
   { 
      $fname = htmlspecialchars($fname); 
   } 
   // added an icon in front of link (ppw) 
   return "<img src='images/mule_icon.gif' border='0'>&nbsp;<a $href>$fname&nbsp;($size)</a>"; 
} 
// ed2k links end 

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

function make_clickable($text) 
{ 
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text); 

  // pad it with a space so we can match things at the start of the 1st line. 
  $ret = ' ' . $text; 
  
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 

// ed2k file links (Meithar): 
// ed2k://|file|fileName|fileSize|fileHash|(optional params)|(optional params)|etc| 
$ret = preg_replace_callback("#(^|(?<=[^\w\"']))(ed2k://\|file\|([^\\/\|:<>\*\?\"]+?)\|(\d+?)\|([a-f0-9]{32})\|(.*?)/?)(?![\"'])(?=([,\.]*?[\s<\[])|[,\.]*?$)#i", "ed2k_link_callback", $ret); 
// ed2k server links: 
// ed2k://|server|serverIP|serverPort 
$ret = preg_replace("#(^|(?<=[^\w\"']))(ed2k://\|server\|([\d\.]+?)\|(\d+?)\|/?)#i", "<a href=\"\\2\" class=\"postLink\">\\3:\\4</a>", $ret); 
// ed2k file links end 

# 
#-----[ FIND ]----------------------------------------------- 
# 
  
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".". 
   $ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret); 

   // Remove our padding.. 
   $ret = substr($ret, 1); 

   return($ret); 
} 

# 
#-----[ AFTER, ADD ]----------------------------------------------- 
# 
  
/** 
* Christian Riesen - Jun 27, 2004 
* Adds the "Add all links to ed2k client" link to the end of the post text 
*/ 
function make_addalled2k_link($text,$post_id) 
{ 
// padding 
$ret = ' ' . $text; 

// dig through the message for all ed2k links! 
// split up by "ed2k:" 
$t_ed2k_raw = explode("ed2k:",$text); 

// The first item is garbage 
unset($t_ed2k_raw[0]); 

// no need to dig through it if there are not at least 2 links! 
$t_ed2k_possibles = count($t_ed2k_raw); 
if ($t_ed2k_possibles > 1) 
{ 
unset($t_ed2k_reallinks); 
foreach ($t_ed2k_raw as $t_ed2k_raw_line) 
{ 
$t_ed2k_parts = explode("|",$t_ed2k_raw_line); 
// This looks now like this (only important parts included 
/* 
[1]=> 
string(4) "file" 
[2]=> 
string(46) "some-filename-here.txt" 
[3]=> 
string(9) "321456789" 
[4]=> 
string(32) "112233445566778899AABBCCDDEEFF11" 
*/ 

// Check the obvious things 
if (strlen($t_ed2k_parts[1]) == 4 AND $t_ed2k_parts[1] === "file" AND strlen($t_ed2k_parts[2]) > 0 AND strlen($t_ed2k_parts[4]) == 32 AND floatval($t_ed2k_parts[3]) > 0) 
{ 
// This is a true link, lets paste it together and put it in an array 
$t_ed2k_reallinks[] = "ed2k://|file|".str_replace("'","\'",$t_ed2k_parts[2])."|".$t_ed2k_parts[3]."|".$t_ed2k_parts[4]."|"; 
} 
} 

// Now lets see if we have 2 or more links 
// Only then, we do our little trick, because otherwise, it would be wasted for one link alone! 
$t_ed2k_confirmed = count($t_ed2k_reallinks); 
if ($t_ed2k_confirmed > 1) 
{ 
$t_ed2kinsert = " \n"; 
$t_ed2kinsert .= "<SCRIPT> "; 
$t_ed2kinsert .= "filearray".$post_id."=new Array; "; 
$t_ed2kinsert .= "n=0; "; 
$i = 0; 
foreach($t_ed2k_reallinks as $t_ed2klink) 
{ 
$t_ed2kinsert .= "filearray".$post_id."[".$i."]='".$t_ed2klink."'; "; 
$i++; 
} 
$t_ed2kinsert .= "iv=false; "; 
$t_ed2kinsert .= "function addfile".$post_id."(){ "; 
$t_ed2kinsert .= " var s=filearray".$post_id."[n]; "; 
$t_ed2kinsert .= " n++; "; 
$t_ed2kinsert .= " if(n==filearray".$post_id.".length && iv){ "; 
$t_ed2kinsert .= " top.clearInterval(iv); "; 
$t_ed2kinsert .= " n=0; "; 
$t_ed2kinsert .= " } "; 
$t_ed2kinsert .= " top.document.location=s; "; 
$t_ed2kinsert .= " return true; "; 
$t_ed2kinsert .= "} "; 
$t_ed2kinsert .= "function addall".$post_id."(){iv=top.setInterval('addfile".$post_id."()',250)} "; 
$t_ed2kinsert .= "</SCRIPT> "; 
//added an icon in front of link (ppw) 
$t_ed2kinsert .= "<img src='images/ed2k-info.gif' border='0'>&nbsp;<a href='javascript:addall".$post_id."()'>Add ".$t_ed2k_confirmed." links to ed2k client</a> "; 
$ret = $ret . $t_ed2kinsert; 
} 
} 

// remove padding 
$ret = substr($ret, 1); 

return($ret); 
} 
// Add all links to ed2k client end 

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

viewtopic.php 

# 
#-----[ FIND ]----------------------------------------------- 
# 
$message = make_clickable($message); 

# 
#-----[ BEFORE, ADD ]----------------------------------------------- 
# 
  
$message = make_addalled2k_link($message,$postrow[$i]['post_id']); // ed2k link and add all 

#-----[ SAVE/CLOSE ALL FILES ]-----------------------------------------------
Reply With Quote
  #9  
Old 01-05-2006, 08:04 AM
Symen_4ab's Avatar
Symen_4ab Symen_4ab is offline
 
Join Date: Jun 2002
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MioTraGusa
God job, but if the ed2k link contain [ ] don?t work correctly :surprised:

is a minor bug, but it is possible to be solved?

tanks for the modification *installed
Quick-note, to resolve the [ and ] problem, you just have to add quotes to the link parsed, so :
[*url=link]title[/url]
becomes
[*url="link"]title[/url]


I tried to modify the plugin, and now it does add the quotes, but the hack doesn't recognize the link as a link anymore

So, if I post a "normal" edk link (without [ or ]), it works, and adds the quotes, but if I post a link with [ in it, it doesn't parse it at all.

edit : Did some code search in the plugin, but regex are a little bit like chinese to me
Reply With Quote
  #10  
Old 01-05-2006, 10:13 AM
MRGTB MRGTB is offline
 
Join Date: Dec 2004
Posts: 548
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Symen_4ab
Quick-note, to resolve the [ and ] problem, you just have to add quotes to the link parsed, so :
[*url=link]title[/url]
becomes
[*url="link"]title[/url]


I tried to modify the plugin, and now it does add the quotes, but the hack doesn't recognize the link as a link anymore

So, if I post a "normal" edk link (without [ or ]), it works, and adds the quotes, but if I post a link with [ in it, it doesn't parse it at all.

edit : Did some code search in the plugin, but regex are a little bit like chinese to me
just a thought, did you try using this instead.

[*url='link']title[/url]

single quotes instead of double to see if that works
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:05 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06325 seconds
  • Memory Usage 2,323KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete