Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: tFF on April 05, 2007, 07:28:10 AM

Title: ed2k links support (with bb-codes)
Post by: tFF on April 05, 2007, 07:28:10 AM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=716)

This mod adds support for ed2k (plain and AICH).

examples are:

1. just a link in bb-codes
[ed2k]ed2k://|file|fakes.rar|1548921|6A11535BC5A77F6DE0CC47EABE9AFF83|/[/ed2k]

2. a link with a description
[ed2k=ed2k://|file|fakes.rar|1548921|6A11535BC5A77F6DE0CC47EABE9AFF83|/]worth downloading[/ed2k]

3. simply a link
ed2k://|file|fakes.rar|1548921|6A11535BC5A77F6DE0CC47EABE9AFF83|/


This mod renders ed2k-links as hyper-text links with an emule icon placed before them. Ed2k-links behave the same way like usual http-links (i.e. ed2k-links may be decorated with/or without bb-codes, with/or without equal sign in bb-code (see examples above)). Also the mod adds a new editor button.


PS Concerning some quiestions asked: This mod is a new one and is not an add-on to mindstorm's one. You better choose one or another. Switching mods shouldn't affect your content and this would be absolutely transparent (this mod is backwards compatible).


Thanks (http://www.simplemachines.org/community/index.php?topic=27643.msg992378#msg992378) to mindstorm for the regexp and emule icon.


Changes:
---------

v3.1.1 by tFF (13 Dec, 2007)
* SMF 1.1.4 (FRESH) and SMF 1.1.4 (UPG) mod's installer compatibility fix
  ps: SMF 1.1.4 fresh installation differs from SMF 1.1.4 upgraded from previous version. That's why the mod
      could be successfully installed on upgraded version, but failed on fresh installation. Subs.php files
      differ in the mentioned versions. This compatibility fix works great with SMF 1.1.4 fresh installation
      and upgraded from previous version (and also with all 1.1.x versions upgraded or fresh).

v3.1.0 by tFF (28 Nov, 2007)
+ human readable size of eDonkey-files (hover your mouse over an eMule icon to see the size)
  ps: the Size was 'hidden' under the eMule icon because it is no more than for informational
      purposes and shouldn't ruin (interfere with) an author's original formatting.

v3.0.1 by tFF (7 Mar, 2007)
* 'descriptive links' (example 2) were not rendered properly for printing

v3.0 by tFF (version number chronology was preserved)
+ added new bb-codes
- removed "ed2kfile" directory
* emule icon was moved to "themes/default/images/bbc"
+ added new editor button

v2.4 by mindstorm (here (http://custom.simplemachines.org/mods/index.php?mod=96))
- just taken as example for rewriting from scratch




issues to investigate:
Title: Re: ed2k links support
Post by: drazprod on April 15, 2007, 09:29:27 PM
very good mod.

The pando and bittorent protocol can are introduce in this mod ...

Sorry for my english.
Title: Re: ed2k links support
Post by: indos on April 27, 2007, 08:56:22 PM
muchas gracias
Title: Re: ed2k links support
Post by: Jmecca2 on May 20, 2007, 12:18:44 PM
THANKS  :)
Title: Re: ed2k links support
Post by: Mindstorm on August 19, 2007, 07:03:54 PM
Hello there. Good work and thanks for the credit! I'd ask you however to also credit Simmiyy, who wrote the icon thingy and part of the handling regexp.

I'd also sugest you chose a different name, having two similar mods with the same name can cause a lot of confusion.
Title: Re: ed2k links support
Post by: iacomac on August 24, 2007, 04:12:47 PM
Fine mod, but it works only if I use the tags [ed2k][/ed2k]. But no, is not a problem. Another bug (bug?): in the name I can't see the spaces. An example:

[icon] This is an example
i see:
[icon] Thisisanexample

Anyway we can use the "." or "_": This.is.an.example or This_is_an_example.

At last: can we see the file dimension? [icon] filename [XXmb]



sorry for my bad english

Cheers,
iacomac
Title: Re: ed2k links support
Post by: FragaCampos on November 27, 2007, 12:31:38 PM
This mod would be perfect with file size display. I had to change to mindstorm's because of that :(
Title: Re: ed2k links support
Post by: tFF on November 27, 2007, 07:48:14 PM
Quote from: iacomac on August 24, 2007, 04:12:47 PM
Another bug (bug?): in the name I can't see the spaces. An example:

[icon] This is an example
i see:
[icon] Thisisanexample

Anyway we can use the "." or "_": This.is.an.example or This_is_an_example.
What spaces and where do you mean? in the original filename? Can you PM me a link that reveals the 'bug'.
PS I do really trim spaces and other unusual stuff as well... Let me see the link first.
Title: Re: ed2k links support
Post by: tFF on November 27, 2007, 08:14:18 PM
Quote from: FragaCampos on November 27, 2007, 12:31:38 PM
This mod would be perfect with file size display. I had to change to mindstorm's because of that :(

mod was updated:
v3.1.0
added human readable size of eDonkey-files (hover your mouse over an eMule icon to see the size).
The Size was 'hidden' under the eMule icon because it is no more than for informational purposes and shouldn't ruin (interfere with) an author's original formatting.

I was not going to put the size after a filename or anywhere else in a text, coz i really don't need it always there. Size is only for info and nothing more. Also i've never needed it and even now. The mod was meant to render ugly emule-links and make them customizable thru bbcodes. Any other info can be seen in any ed2k-client (to say more ed2k gives enough time to explore file's details while waiting in a queue). :) Btw, the mod will not show size figures in a printed version (guess, additional size info would not make things clearer with full ed2k-links (with those brackets and pipes and other stuff) already there).

That's my humble opinion.

Anyway, here you are. Catching up the requests.
Title: Re: ed2k links support
Post by: FragaCampos on November 28, 2007, 07:35:19 AM
Thanks a lot tFF  for your time and will to help :D
Changing again to you mod  8)

Take care!
Title: Re: ed2k links support
Post by: ディン1031 on December 11, 2007, 03:06:35 AM
Somehow, the new version could not installed on a fresh and new installed smf :x.
Each time a parse error in Subs.php occur. (I only would like to test a compatible thing to my hide tag special mod, because someone told me there is a bug in my mod with this :x or think that it have something to do with the mod, but it's difficult to test if i can't install it ;D .oO(okay i'm only lazy, because i can install it also but i think you should know it ;P)).

Bye
DIN1031
Title: Re: ed2k links support
Post by: tFF on December 11, 2007, 10:07:00 AM
It appears to be that there were 3 spaces deleted in new Subs.php (1.1.4) but these spaces remained untouched in old Subs.php after an upgrade to 1.1.4. So there are two legitimate fragments with and without spaces. Take a look:
(http://tff.msk.ru/files/pics/smf_ed2k/2007-12-11_180444.gif)

And my mod relied on this fragment.
I've fixed it already, but i have to re-chek it now with previous 1.1.x versions. So i'll upload it later.
Title: Re: ed2k links support
Post by: tFF on December 13, 2007, 12:53:20 AM
Mod was updated:
v3.1.1
  * SMF 1.1.4 (FRESH) and SMF 1.1.4 (UPG) mod's installer compatibility fix
  ps: SMF 1.1.4 fresh installation differs from SMF 1.1.4 upgraded from previous version. That's why the mod
      could be successfully installed on upgraded version, but failed on fresh installation. Subs.php files
      differ in the mentioned versions. This compatibility fix works great with SMF 1.1.4 fresh installation
      and upgraded from previous version (and also with all 1.1.x versions upgraded or fresh).


Once again. There are two legitimate Subs.php which differ in one fragment (or even more). One Subs.php you get when you install SMF from scratch and another one when you upgrade from previous version. So, my mod could be successfully installed on an upgraded SMF version, but failed to install on fresh SMF installation.
So here is a compatibility fix which works great with all of SMFs either fresh or upgraded. Moreover i've re-checked it once again with all 1.1.x versions of SMF (1.1.1 thru 1.1.4). It works great with all these versions no matter either they are fresh or upgraded.


Quote from: ディン1031 on December 11, 2007, 03:06:35 AM
Somehow, the new version could not installed on a fresh and new installed smf :x.
Thank you for the comment.
Title: Re: ed2k links support
Post by: allumius on December 13, 2007, 10:53:37 AM
I have one problem

if i past this elink
ed2k://|file|Cuento%20de%20navidad%20(pelicula,%20no%20dibujos!)-Muchas%20Gracias%20Mr.%20Scrooge.avi|1472454656|0DE7720812AFE4A85DF253E055C621FC|/

the link in the post is
QuoteCuento%20de%20navidad%20(pelicula,%20no%20dibujos!)-Muchas%20Gracias%20Mr.%20Scrooge.avi

But the real title is
QuoteCuento de navidad (pelicula, no dibujos!)-Muchas Gracias Mr. Scrooge.avi

Why is %20 and not  (white space)?
Title: Re: ed2k links support
Post by: tFF on December 13, 2007, 10:11:37 PM
Quote from: allumius on December 13, 2007, 10:53:37 AM
Why is %20 and not  (white space)?
Links shouldn't have spaces in them... So all spaces get substituted by space's character code.
code for [space] = 32 decimal = 20 hexadecimal
%20 means its hexadecimal representation in html notation.

This is true not only for ed2k-links but for other links as well. Those %20 and other encoded symbols should be automatically decoded by related software (browser, ed2k-client etc.).

To solve your prob you can use the second format of ed2k-bbcode
Quote2. a link with a description
[ed2k=ed2k://|file|fakes.rar|1548921|6A11535BC5A77F6DE0CC47EABE9AFF83|/]worth downloading[/ed2k]
instead of "worth downloading" u can write whatever you want, even your filename without %20's.

PS You have all the flexibility in decoration with bb-codes. Just use your imagination to get what you want.
Title: Re: ed2k links support (with bb-codes)
Post by: allumius on December 14, 2007, 06:14:46 AM
But if you have this elinks?
ed2k://|file|Pocoyo%201x01%20Musica%20Maestro%20[DVDrip]%20[TusSeries.com].avi|64286720|4D79DE0B2C7F7120DBD2CEA079EA788F|/

The 2º option not work!!

And you can add this other options to mod?

QuoteAdds support for ed2k links in <a href> tags
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on December 14, 2007, 07:57:03 AM
Quote from: allumius on December 14, 2007, 06:14:46 AM
And you can add this other options to mod?
QuoteAdds support for ed2k links in <a href> tags
You don't need any mod for it. You just need an html-enabled forum.

Quote from: allumius on December 14, 2007, 06:14:46 AM
The 2º option not work!!
That's because you are not attentive enough!!!

Don't you see that the bb-code ends with ']' and your link breaks at first ']'??? Edit the filename and remove all [DVDrip] and [TusSeries.com] from it. Don't worry 'coz different filenames make no big sense for edonkey...
You'll get this for instance
[ed2k=ed2k://|file|Pocoyo%201x01%20Musica%20Maestro.avi|64286720|4D79DE0B2C7F7120DBD2CEA079EA788F|/]Pocoyo 1x01 Musica Maestro[/ed2k]

PS
This topic is for support, not for teaching
Title: Re: ed2k links support (with bb-codes)
Post by: Darknico on January 11, 2008, 09:39:14 PM
It is possibile to have the stats by http://tothbenedek.hu/ed2kstats ??
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on January 12, 2008, 04:46:08 AM
Quote from: Darknico on January 11, 2008, 09:39:14 PM
It is possibile to have the stats by http://tothbenedek.hu/ed2kstats ??
Maybe... I have no time for it now. I've read the page for developers there. Everything must be easy enough.
But my opinion is: if you know how to get stats then go and get it. Stats, IMHO, has nothing to do with the mod, there is not only this service providing such information and linking with this service may make the mod unstable and dependent on this service's quality. Imagine that some day the service stops responding to outer request thus making your whole forum unstable thru the mod (even with AJAX-based requests). So, my opinion is: any mod should provide reasonable functions, every extra functions leads to either junk in a database (i.e. various settings for tuning extra services) or instability of a forum itself.
So, I'll think twice before implementing such features even if I have time for scripting.
Title: Re: ed2k links support (with bb-codes)
Post by: Darknico on January 12, 2008, 04:50:14 AM
ok, thanks
Title: Re: ed2k links support (with bb-codes)
Post by: Darknico on January 14, 2008, 02:46:25 PM
in the error log

Quotehttp://www.mystiteforum/index.php?topic=243.0

8: Undefined offset: 3
File: /home/mysite/public_html/forum/Sources/Subs.php
Linea: 963


in the line 963


// tFF - ed2k
function ed2k_readableSize ($ed2k_link) {
preg_match('~(\s|^)(ed2k://\|file\|.+?\|(.+?)\|.+?)(\s|$)~i', $ed2k_link, $matches);
$size=$matches[3];

$loop = 0;
$suffix = array ("Bytes","KB","MB","GB","TB"); //TeraByte is max possible
while ( ($size > 1024) && ($loop < 4) ) { //loop shouldn't be > 4 so the TB is max
$loop++;
$size /= 1024;
}


return round($size, 2) . " " . $suffix[$loop];
}

// /tFF - ed2k


Title: Re: ed2k links support (with bb-codes)
Post by: tFF on January 14, 2008, 02:53:56 PM
Quote from: Darknico on January 14, 2008, 02:46:25 PM
in the error log
I need an ed2k-link which causes this error.
And I need either line numbers in the code fragment u've quoted or the exact line number 963 (which one). I can only guess the nature of the error and where it may occur but i need more data.

Added later:
I suspect that it occurs at (if it's line 963)
$size=$matches[3];
which means the link is invalid and has no size info (it means it doesn't satisfy ed2k-link structure)
So, gimme the exact ed2k-link pls (and the line number).
Title: Re: ed2k links support (with bb-codes)
Post by: Darknico on January 14, 2008, 03:01:21 PM
this link is only a example, for my test

ed2k://|file|RAOH_GAIDEN_DC_(SUB-ITA)_RIP_BY_Danielfor78.avi|722523538|549BC8F30C557700A3255A941C6F87FC|h=THIZLVY6KY7IQUHVKUC4T35PXJPUVAUG|/

result 0 Mb

line 963 is

$size=$matches[3];
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on January 14, 2008, 03:18:32 PM
Thanks. I'll debug it, coz i see no problems in my regexp parser (it finds no errors).
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on January 14, 2008, 03:30:55 PM
So, i've posted a msg with
ed2k://|file|RAOH_GAIDEN_DC_(SUB-ITA)_RIP_BY_Danielfor78.avi|722523538|549BC8F30C557700A3255A941C6F87FC|h=THIZLVY6KY7IQUHVKUC4T35PXJPUVAUG|/
and i have nothing to debug 'coz i have no problems with it. Take a look:
(http://tff.msk.ru/files/pics/smf_ed2k/2008-01-14_232808.png)

And my error log is clean.
tested on SMF 1.1.4

I can not reproduce the bug.
Title: Re: ed2k links support (with bb-codes)
Post by: Darknico on January 14, 2008, 03:36:41 PM
(http://img153.imageshack.us/img153/3488/ed2ksh5.jpg)

my single edit:

'content' => '<img src="__ed2k_ico__" alt="Edonkey Link" title="ed2k: __ed2k_size__" />&nbsp;<a href="$1">__ed2k_name__</a> (__ed2k_size__)',

Title: Re: ed2k links support (with bb-codes)
Post by: tFF on January 14, 2008, 03:53:09 PM
Quote from: Darknico on January 14, 2008, 03:36:41 PM
my single edit:
Just for a test i've inserted your line instead of mine and posted
ed2k://|file|RAOH_GAIDEN_DC_(SUB-ITA)_RIP_BY_Danielfor78.avi|722523538|549BC8F30C557700A3255A941C6F87FC|h=THIZLVY6KY7IQUHVKUC4T35PXJPUVAUG|/
[ed2k]ed2k://|file|RAOH_GAIDEN_DC_(SUB-ITA)_RIP_BY_Danielfor78.avi|722523538|549BC8F30C557700A3255A941C6F87FC|h=THIZLVY6KY7IQUHVKUC4T35PXJPUVAUG|/[/ed2k]
[ed2k=ed2k://|file|RAOH_GAIDEN_DC_(SUB-ITA)_RIP_BY_Danielfor78.avi|722523538|549BC8F30C557700A3255A941C6F87FC|h=THIZLVY6KY7IQUHVKUC4T35PXJPUVAUG|/]lalaa[/ed2k]


and still have no problems
(http://tff.msk.ru/files/pics/smf_ed2k/2008-01-14_235143.png)

Added later:
If you are aware of php scripting, I would advise you to take any php-debugger and see your forum from inside (as far as i'm unable to reproduce this glitch).

Added later:
Or if you can give me a clue how to reproduce it i'll do it myself.
Title: Re: ed2k links support (with bb-codes)
Post by: Darknico on January 14, 2008, 04:12:07 PM
ok, resolve
the problem is the space


[ed2k]ed2k://|file|RAOH_GAIDEN_DC_(SUB-ITA)_RIP_BY_Danielfor78.avi|722523538|549BC8F30C557700A3255A941C6F87FC|h=THIZLVY6KY7IQUHVKUC4T35PXJPUVAUG|/[/ed2k]


It's OK :)



[ed2k]
ed2k://|file|RAOH_GAIDEN_DC_(SUB-ITA)_RIP_BY_Danielfor78.avi|722523538|549BC8F30C557700A3255A941C6F87FC|h=THIZLVY6KY7IQUHVKUC4T35PXJPUVAUG|/
[/ed2k]


Not Work :(
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on January 14, 2008, 04:21:16 PM
Ok.
I think I don't have to add "new line" characters workaround in the mod, coz these tags are not for multi-line content.
The only valid content for ed2k-tags is single-line.

Added later:
or maybe I will trim them automatically next time, not today. :)
Title: Re: ed2k links support (with bb-codes)
Post by: Darknico on January 14, 2008, 04:22:42 PM
ok, thanks for the support ;)
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on January 14, 2008, 04:49:44 PM
as a quick fix of this issue you can swap the lines
$humanSize = ed2k_readableSize($data);
and
$data = strtr($data, array(\'<br />\' => \'\', \' \' => \'\', \'&nbsp;\' => \'\'));

before:
$humanSize = ed2k_readableSize($data);
$data = strtr($data, array(\'<br />\' => \'\', \' \' => \'\', \'&nbsp;\' => \'\'));


after:
$data = strtr($data, array(\'<br />\' => \'\', \' \' => \'\', \'&nbsp;\' => \'\'));
$humanSize = ed2k_readableSize($data);


change it twice (you will find these lines in two code fragments).

ATTENTION!!! everyone:
If you modify mod's code in Subs.php after the mod is installed you will likely have problems with uninstalling it later. You may comment out original lines to restore them before uninstall.
Title: Re: ed2k links support (with bb-codes)
Post by: Darknico on January 14, 2008, 04:58:08 PM
Great!!!
Thanks!!

QuoteATTENTION!!! everyone:
If you modify mod's code in Subs.php after the mod is installed you will likely have problems with uninstalling it later. You may comment out original lines to restore them before uninstall.

no problem
don't use the package ;)
Title: Re: ed2k links support (with bb-codes)
Post by: tomcat2200 on January 16, 2008, 05:40:04 AM
Im not sure where all of this went as I have been searching the multitude of posts here looking for the solution.

I have uploaded this latest version into my smf 1.1.4 setup.

I get an error when I try to install this.

The error reads: Modification parse error

If i run the install anyway, nothing happens. no ed2k link responds. I even tried the three "fake" ed2k posts demonstrated here.

Nothing at all. just the text string of the ed2k link.

I almost hate to ask, but please help.
Title: Re: ed2k links support (with bb-codes)
Post by: tomcat2200 on January 16, 2008, 03:54:53 PM
]Hi all,

I have discovered that when SMF is nested within xBtit, that no package will ever parse correctly.

I ended up having to extract the code from your mod and locate the insertion points. So I did everything manually.

It would have been easier if the insertion points hadn't been mixed between insert before and insert after, being reversed. I find it immensely easier to install code manually, using the modality of sourceforge for such projects as phpbb3 and such, than to having to deal with a weak package installer that is abortive at the drop of the hat.

My thanks to tFF for the code snippets. I have also recently obtained some, more sophisticated code segments for mounting the mule icon ahead of the line and adding the index link at the end as well as file size, which was suggested in an earlier post from another person. I will make it available as I pick it appart and place it.
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on January 17, 2008, 08:29:04 AM
Quote from: tomcat2200 on January 16, 2008, 03:54:53 PM
I have discovered that when SMF is nested within xBtit, that no package will ever parse correctly.

I ended up having to extract the code from your mod and locate the insertion points. So I did everything manually.
I'm not responsible for any third-party changes to subs.php and i'm not a prophet to predict all those changes by third-party integration solutions. Only you - the owner - is responsible for all possible side effects. Mod's installation script is based on the original SMF code fragments which are stable and are unlikely to be changed by other mods.

Quote from: tomcat2200 on January 16, 2008, 03:54:53 PM
It would have been easier if the insertion points hadn't been mixed between insert before and insert after, being reversed.
Yeah, that is really hard to get, but if u get that u'll see the logic... but still it's frustrating.

Quote from: tomcat2200 on January 16, 2008, 03:54:53 PM
My thanks to tFF for the code snippets. I have also recently obtained some, more sophisticated code segments for mounting the mule icon ahead of the line and adding the index link at the end as well as file size, which was suggested in an earlier post from another person. I will make it available as I pick it appart and place it.
Waiting for the link. :)

PS btw, what "index link"?
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on January 17, 2008, 08:29:57 AM
Quote from: Darknico on January 14, 2008, 04:58:08 PM
no problem
don't use the package ;)
ah?
Title: Re: ed2k links support (with bb-codes)
Post by: Darknico on January 17, 2008, 08:34:36 AM
Quote from: tFF on January 17, 2008, 08:29:57 AM
Quote from: Darknico on January 14, 2008, 04:58:08 PM
no problem
don't use the package ;)
ah?

Sorry my English, but I'm Italian...

I made the changes manually without use package manager
Title: Re: ed2k links support (with bb-codes)
Post by: tomcat2200 on January 19, 2008, 08:59:28 PM
Here is the function core for the "modified" ED2K link. The index link I referred to is the look up to see the number of current sources for the file. There is a small gif I have for the index link that looks like a small graph, its cute. This uses the same mule icon on the front but the filesize is shown in brackets at the end of the file, followed by the index link icon. The user can click on the index link to get the number of sources currently available for the file.

I think the following code could be coopted and integrated here with minimal effort. If no one here does it, i will eventually get around to it. As it is I am in the middle of a push to get a site on-line for someone who needs it yesterday. The code only seems to extend the same logic used in the original post here. If someone integrates it, let me know. This one works quite well in phpbb3. There are also a few snippets of code that go with this but mostly apply to the phpbb3 context. I do have the complete change mod if anyone is interested.


// eD2k links processing
function humanize_size ($size, $rounder = 0)
{
$sizes = array('Bytes', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb');
$rounders = array(0, 1, 2, 2, 2, 3, 3, 3, 3);
$ext = $sizes[0];
$rnd = $rounders[0];

if ($size < 1024)
{
$rounder = 0;
$format = '%.' . $rounder . 'f Bytes';
}
else
{
for ($i = 1, $cnt = count($sizes); ($i < $cnt && $size >= 1024); $i++)
{
$size = $size / 1024;
$ext = $sizes[$i];
$rnd = $rounders[$i];
$format = '%.' . $rnd . 'f ' . $ext;
}
}

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

return sprintf($format, round($size, $rounder));
}

function ed2k_link_callback ($m)
{
$max_len = 100;
$href = 'href="' . $m[2] . '" class="postlink"';
$fname = rawurldecode($m[3]);
$fname = preg_replace('/&amp;/i', '&', $fname);
$size = humanize_size($m[4]);

if (strlen($fname) > $max_len)
{
$fname = substr($fname, 0, $max_len - 19) . '...' . substr($fname, -16);
}
if (preg_match('#[<>"]#', $fname))
{
$fname = htmlspecialchars($fname);
}

// return "ed2k: <a $href>$fname&nbsp;&nbsp;[$size]</a> <a href='http://www.emugle.com/details.php?f=$m[5]' target='_blank'><img src='images/emugle.gif' border='0' title='eMugle statistics' style='vertical-align: text-bottom;' /></a>";
return "ed2k: <a $href>$fname&nbsp;&nbsp;[$size]</a> <a href='http://tothbenedek.hu/ed2kstats/ed2k?hash=$m[5]' target='_blank'><img src='images/stats.gif' border='0' title='File statistics' style='vertical-align: text-bottom;' /></a>";
}

function process_ed2k($text)
{
// pad it with a space so we can match things at the start of the 1st line.
$ret = ' ' . $text;

// Patterns and replacements for URL processing
$patterns = array();
$replacements = array();

// [url=http://ed2k://|file|...]ed2k://|file|...[/url] code
$patterns[] = '#\[url\](ed2k://\|file\|(.*?)\|\d+\|\w+\|(h=\w+\|)?/?)\[/url\]#is';
$replacements[] = '<a href="$1" class="postlink">$2</a>';
// [url=http://ed2k://|file|...]name[/url] code
$patterns[] = '#\[url=http://(ed2k://\|file\|(.*?)\|\d+\|\w+\|(h=\w+\|)?/?)\](.*?)\[/url\]#si';
$replacements[] = '<a href="$1" class="postlink">$4</a>';
// [url=http://ed2k://|server|ip|port|/]ed2k://|server|ip|port|/[/url] code
$patterns[] = '#\[url\](ed2k://\|server\|([\d\.]+?)\|(\d+?)\|/?)\[/url\]#si';
$replacements[] = 'ed2k server: <a href="$1" class="postlink">$2:$3</a>';
// [url=http://ed2k://|server|ip|port|/]name[/url] code
$patterns[] = '#\[url=http://(ed2k://\|server\|[\d\.]+\|\d+\|/?)\](.*?)\[/url\]#si';
$replacements[] = '<a href="$1" class="postlink">$2</a>';
// [url=http://ed2k://|friend|name|ip|port|/]ed2k://|friend|name|ip|port|/[/url] code
$patterns[] = '#\[url\](ed2k://\|friend\|(.*?)\|[\d\.]+\|\d+\|/?)\[/url\]#si';
$replacements[] = 'ed2k friend: <a href="$1" class="postlink">$2</a>';
// [url=http://ed2k://|friend|name|ip|port|/]name[/url] code
$patterns[] = '#\[url=(ed2k://\|friend\|(.*?)\|[\d\.]+\|\d+\|/?)\](.*?)\[/url\]#si';
$replacements[] = '<a href="$1" class="postlink">$3</a>';

$ret = preg_replace($patterns, $replacements, $ret);

$ret = preg_replace_callback("#(^|(?<=[^\w\"']))(ed2k://\|file\|([^\\/\|:<>\*\?\"]+?)\|(\d+?)\|([a-f0-9]{32})\|(.*?)/?)(?![\"'])(?=([,\.]*?[\s<\[])|[,\.]*?$)#i", "ed2k_link_callback", $ret);
// ed2k://|server|serverIP|serverPort
$ret = preg_replace("#(^|(?<=[^\w\"']))(ed2k://\|server\|([\d\.]+?)\|(\d+?)\|/?)#i", "ed2k server: <a href=\"\\2\" class=\"postLink\">\\3:\\4</a>", $ret);
// ed2k://|friend|name|clientIP|clientPort
$ret = preg_replace("#(^|(?<=[^\w\"']))(ed2k://\|friend\|([^\\/\|:<>\*\?\"]+?)\|([\d\.]+?)\|(\d+?)\|/?)#i", "ed2k friend: <a href=\"\\2\" class=\"postLink\">\\3</a>", $ret);
// -- END --

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

return($ret);
}

// eD2k Add all links feature
function make_addalled2k_link($text, $post_id)
{
// padding
$ret = ' ' . $text;

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

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

// no need to dig through it if there are not at least 2 links
$ed2k_possibles = count($ed2k_raw);
if ($ed2k_possibles > 1)
{
unset($ed2k_real_links);
foreach ($ed2k_raw as $ed2k_raw_line)
{
$ed2k_parts = explode('|', $ed2k_raw_line);
// This looks now like this (only important parts included)
/*
[1]=>
string(4) "file"
[2]=>
string(46) "filename.extension"
[3]=>
string(9) "321456789"
[4]=>
string(32) "112233445566778899AABBCCDDEEFF11"
[5]=>
string(?) "source or AICH hash"
*/

// Check the obvious things
if (strlen($ed2k_parts[1]) == 4 AND $ed2k_parts[1] == 'file' AND strlen($ed2k_parts[2]) > 0 AND floatval($ed2k_parts[3]) > 0 AND strlen($ed2k_parts[4]) == 32)
{
// This is a true link, lets paste it together and put it in an array
if (substr($ed2k_parts[5], 0, 2) == 'h=' || substr($ed2k_parts[5], 0, 7) == 'sources')
{
$ed2k_real_links[] = 'ed2k://|file|' . str_replace('\'', '\\\'', $ed2k_parts[2]) . '|' . $ed2k_parts[3] . '|' . $ed2k_parts[4] . '|' . $ed2k_parts[5] . '|/';
}
else
{
$ed2k_real_links[] = 'ed2k://|file|' . str_replace('\'', '\\\'', $ed2k_parts[2]) . '|' . $ed2k_parts[3] . '|' . $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
$ed2k_confirmed = count($ed2k_real_links);
if ($ed2k_confirmed > 1)
{
$ed2k_insert = '<br /><br />';
$ed2k_insert .= '<SCRIPT>';
$ed2k_insert .= 'filearray' . $post_id . '=new Array;';
$ed2k_insert .= 'n=0;';
$i = 0;
foreach($ed2k_real_links as $ed2k_link)
{
$ed2k_insert .= 'filearray' . $post_id . '[' . $i . ']=\'' . $ed2k_link . '\';';
$i++;
}
$ed2k_insert .= 'iv=false;';
$ed2k_insert .= 'function addfile' . $post_id . '()';
$ed2k_insert .= '{';
$ed2k_insert .= ' var s=filearray' . $post_id . '[n];';
$ed2k_insert .= ' n++;';
$ed2k_insert .= ' if(n==filearray' . $post_id . '.length && iv)';
$ed2k_insert .= ' {';
$ed2k_insert .= ' top.clearInterval(iv);';
$ed2k_insert .= ' n=0;';
$ed2k_insert .= ' }';
$ed2k_insert .= ' top.document.location=s;';
$ed2k_insert .= ' return true;';
$ed2k_insert .= '}';
$ed2k_insert .= 'function addall' . $post_id . '(){iv=top.setInterval("addfile' . $post_id . '()",250)}';
$ed2k_insert .= '</SCRIPT>';
$ed2k_insert .= '<span class="gensmall"><a href="javascript:addall' . $post_id. '()" class="postlink">[ Add all ' . $ed2k_confirmed . ' links to your ed2k client ]</a></span>';
$ret = $ret . $ed2k_insert;
}
}

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

return($ret);
}

Title: Re: ed2k links support (with bb-codes)
Post by: Wingman on March 01, 2008, 01:58:57 PM
Ok I had the same problem and i tried the quick fix...

But it doesn't work with me :(
The strange thing is that i get the same error of Darknico, but it doesn't happen only when viewing an ed2k link, but also in other sections of the forum. For example the index page.

Maybe it conflicts with other mods? i have nothing installed which requires huge code changes (better: they only provide added code), except youtube tag and tinyportal.

As soon as i can i will remove tinyportal since i think that it requires too much code changes, it's still buggy and provides many and many features that i will never need ;)
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on March 03, 2008, 01:47:47 PM
Quote from: Wingman on March 01, 2008, 01:58:57 PM
Ok I had the same problem and i tried the quick fix...
This error occurs only when bb-code parser comes thru ed2k tags. When parser finds ed2k tags it starts executing ed2k subroutines. This error, you're talking about, says that the parser has called a function for retrieving filesize from ed2k link, but if this error happens it means that the function hasn't got any valid ed2k-link. What means that ed2k-tags were improperly used or it was damaged during parsing a post.
If this is the case, then there is no place for incompatiblility. I hope that very much.

This is only ok for the exact piece of code and the error described above (before the quick-fix). If somehow it occurs with the same type of error but in some other place then reasons and remedies may be completely different.

Anyway it would be better to debug and see from inside.
Title: Re: ed2k links support (with bb-codes)
Post by: coris on May 30, 2008, 03:39:53 PM
Hello, thanks for the mod, but it give me this error:

Parse error: syntax error, unexpected '.' in /mounted-storage/home91a/sub007/sc42775-VLOU/thephoenix-team.com/smf/Sources/Subs.php on line 1863

$data = preg_replace('~(?<=[\s>\.(;\'"]|^)(ed2k://\|file\|(.+?)\|.+?)(?=[?,\s\[\]()*\\\]|$|<br />|&nbsp;|&gt;|&lt;|&quot;|'|\.(?:\.|;|&nbsp;|\s|$|<br />))~i', '[ed2k]$1[/ed2k]', $data);
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on May 30, 2008, 04:25:33 PM
Quote from: coris on May 30, 2008, 03:39:53 PM
Hello, thanks for the mod, but it give me this error:

Strange things are.

In the notification of your post by e-mail i've got the following code fragment:
// tFF - ed2k // eDonkey links then...
               if (!isset($disabled['ed2k']) && strpos($data, 'ed2k://') !== false)
               {
                     $data = preg_replace('~(?<=[\s>\.(;\'"]|^)(ed2k://\|file\|(.+?)\|.+?)(?=[?,\s\[\]()*\\\]|$|<br />|&nbsp;|&gt;|&lt;|&quot;|'|\.(?:\.|;|&nbsp;|\s|$|<br />))~i', '[ed2k]$1[/ed2k]', $data);
               }
               // tFF - ed2k

But here in your post there is a single line of code and no any reference that you had modified the post. So, merging all together I'm able to locate the exact place. And here comes the second funny thing.

The second funny thing is: I see no such line of code u mentioned above. I've just searched thru all versions of the mod i ever released (3.0.1 - 3.1.1). Nothing.

Take a look at the latest version (3.1.1), the code should be like this there:
// tFF - ed2k
// eDonkey links then...
if (!isset($disabled['ed2k']) && strpos($data, 'ed2k://') !== false)
{
$data = preg_replace('~(?<=[\s>\.(;\'"]|^)(ed2k://\|file\|(.+?)\|.+?)(?=[?,\s\[\]()*\\\]|$|<br />|&nbsp;|&gt;|&lt;|&quot;|&#039;|\.(?:\.|;|&nbsp;|\s|$|<br />))~i', '[ed2k]$1[/ed2k]', $data);
}
// /tFF - ed2k


Compare
yours:

$data = preg_replace('~(?<=[\s>\.(;\'"]|^)(ed2k://\|file\|(.+?)\|.+?)(?=[?,\s\[\]()*\\\]|$|<br />|&nbsp;|&gt;|&lt;|&quot;|'|\.(?:\.|;|&nbsp;|\s|$|<br />))~i', '[ed2k]$1[/ed2k]', $data);

and mine:

$data = preg_replace('~(?<=[\s>\.(;\'"]|^)(ed2k://\|file\|(.+?)\|.+?)(?=[?,\s\[\]()*\\\]|$|<br />|&nbsp;|&gt;|&lt;|&quot;|&#039;|\.(?:\.|;|&nbsp;|\s|$|<br />))~i', '[ed2k]$1[/ed2k]', $data);


Finally. As far as your code is not original, I won't parse your regular expression and the code for errors. I have no idea what is that to the moment.

Later:
Ok... I see the difference:
"&#039;" in mine turned into "'" (single quote) in yours thus it terminates the string and makes the code invalid.
Fix it and see what happens.
Title: Re: ed2k links support (with bb-codes)
Post by: coris on May 30, 2008, 04:54:13 PM
Thanks tFF, now works perfectly. I follow the instructions from this link: http://custom.simplemachines.org/mods/index.php?mod=716

Maybe, you should update it, to fix that error.

Thanks again

LATER

This type of e-link doesn't work:
ed2k://|file|(ThePhoenixTeam) Super GALS! -DVDRip Dual- 27 [CA4A4319].mkv|295222080|3D73494CC43364459AEABB96A5EF2370|h=O7UIOJZ4KHSWIQ43GJVZKYBIN5RPQ26X|/

It could be because it have the CRC code?

Another things, the spaces code (%20) can't disapeared and turn to a space in the link?
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on May 30, 2008, 05:02:58 PM
Quote from: coris on May 30, 2008, 04:54:13 PM
Maybe, you should update it, to fix that error.
I can't update that stuff. As far as i can see, manual installation instruction is purely automatic: guess, it parses mod's installation script and renders it on a page. Somehow it also converts symbol codes into alphanumeric representation.

It's time for bug report to simplemachines' web-developers.. I would be grateful if you sent them such report. :)

Quote from: coris on May 30, 2008, 04:54:13 PM
LATER

This type of e-link doesn't work:
ed2k://|file|(ThePhoenixTeam) Super GALS! -DVDRip Dual- 27 [CA4A4319].mkv|295222080|3D73494CC43364459AEABB96A5EF2370|h=O7UIOJZ4KHSWIQ43GJVZKYBIN5RPQ26X|/

It could be because it have the CRC code?
Have no idea... I'll check when time permits.

Quote from: coris on May 30, 2008, 04:54:13 PM
Another things, the spaces code (%20) can't disapeared and turn to a space in the link?
Yeah... I've got such requests in this thread already and i could only advise to replace spaces with something else as far as filename means not as too much for ed2k-link as its hash.
Honestly, I haven't updated myself to SMF 1.1.5 yet and that's why I've postponed further requests implementation and development until i have some time to update my forum, check twice and then implement all todos and stuff.
Title: Re: ed2k links support (with bb-codes)
Post by: coris on May 31, 2008, 06:48:03 AM
Yes, I know that the filename is not really important as the hash, but is more pretty to see the links with the spaces in the link :P

Thanks for your time
Title: Re: ed2k links support (with bb-codes)
Post by: ë®â§e® on June 04, 2008, 09:21:19 AM
Can i update the mod with 1.1.5 version? I tried to do it manually bu it doesn't readed the bbcode e so anything has changed...  How to add manually informations about file's size ?
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on June 04, 2008, 09:32:28 AM
Quote from: ë®â§e® on June 04, 2008, 09:21:19 AM
Can i update the mod with 1.1.5 version? I tried to do it manually bu it doesn't readed the bbcode e so anything has changed...  How to add manually informations about file's size ?
I'll do my best to update it as soon as possible. Sorry for inconvenience.
Title: Re: ed2k links support (with bb-codes)
Post by: ë®â§e® on June 04, 2008, 12:23:56 PM
ok guy, i'll wait for your update, see you soon, bye
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on June 04, 2008, 12:53:00 PM
I've just installed clean SMF115 (not an update from 114). Then applied the mod, everything has been installed successfully. So current release has just been promoted to be 1.1.5 compatible.

Second, you could try to download the mod for installation from your hard drive (with 'Browse'). In the mod's installation script it is stated that the mod is compatible with SMF from 1.1.1 thru 1.1.99 and 1.1 (1.1 branch in brief).

Finally, I do remember that there were some problems (in this thread) that the mod couldn't be installed on an older upgraded SMF. That was fixed in previous releases and shouldn't occur. Nevertheless I'll check it later on.

Added later:
Finally, I've tested the mod on both installations: fresh and upgraded (1.1.3 thru 1.1.5). Everything works fine.

Next release will address issues with spaces and linefeeds.
Title: Re: ed2k links support (with bb-codes)
Post by: coris on June 05, 2008, 04:10:13 PM
Quote from: coris on May 30, 2008, 04:54:13 PM
This type of e-link doesn't work:
ed2k://|file|(ThePhoenixTeam) Super GALS! -DVDRip Dual- 27 [CA4A4319].mkv|295222080|3D73494CC43364459AEABB96A5EF2370|h=O7UIOJZ4KHSWIQ43GJVZKYBIN5RPQ26X|/

I found why this type of e-link doesn't work. Is beacuse the brackets. I hope that you can fix that, cause this mod is relly usefull.

Thanks again
Title: Re: ed2k links support (with bb-codes)
Post by: ë®â§e® on June 06, 2008, 08:59:33 AM
Thank Ya man
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on June 06, 2008, 11:31:07 AM
Quote from: coris on June 05, 2008, 04:10:13 PM
I found why this type of e-link doesn't work. Is beacuse the brackets. I hope that you can fix that, cause this mod is relly usefull.
Not simply 'brackets' but SQUARE brackets u mean. The answer is: no chance to fix it for the way you post your link.
SQUARE brackets are reserved for bb-codes... So if u trace smf's bb-codes parsing logic then u'll see that
ed2k://|file|(ThePhoenixTeam) Super GALS! -DVDRip Dual- 27 [CA4A4319].mkv|295222080|3D73494CC43364459AEABB96A5EF2370|h=O7UIOJZ4KHSWIQ43GJVZKYBIN5RPQ26X|/
Title: Re: ed2k links support (with bb-codes)
Post by: coris on June 06, 2008, 06:24:48 PM
Ok, thanks tFF. I'll use that form. Finally I hope that you can fix the issue with the spaces :)

I hope not being very tedious.
Title: Re: ed2k links support (with bb-codes)
Post by: coris on July 01, 2008, 12:28:32 PM
tFF have you take a look about how to fix the spaces in the names of e-links?

Thanks.
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on July 06, 2008, 10:29:08 AM
Quote from: coris on July 01, 2008, 12:28:32 PM
tFF have you take a look about how to fix the spaces in the names of e-links?
haven't yet. sorry. that summer season gives no chance for free coding. :) i'll do my best to fix it as soon as possible.
Title: Re: ed2k links support (with bb-codes)
Post by: coris on July 06, 2008, 05:27:39 PM
Ok tFF. No problem, when you can will be ok :)
Title: Re: ed2k links support (with bb-codes)
Post by: coris on August 18, 2008, 03:44:39 PM
There's any new? Thanks
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on August 18, 2008, 03:47:37 PM
Quote from: coris on August 18, 2008, 03:44:39 PM
There's any new? Thanks
September. I'll do my best. I'll try. :)
Title: Re: ed2k links support (with bb-codes)
Post by: EkSeS on March 17, 2009, 11:19:12 PM
Quote from: tFF on August 18, 2008, 03:47:37 PM
Quote from: coris on August 18, 2008, 03:44:39 PM
There's any new? Thanks
September. I'll do my best. I'll try. :)

Now it's March :)

Do someone think about update this package to smf rc1 ( or later rc2 ) ?
Title: Re: ed2k links support (with bb-codes)
Post by: tFF on October 17, 2009, 07:44:31 PM
Hello everyone.

Quote from: EkSeS on March 17, 2009, 11:19:12 PM
Do someone think about update this package to smf rc1 ( or later rc2 ) ?
I think it's no sense to upgrade this mod for RC.
Let's wait for SMF2 release and see if EDonkey mod is still requested.
Title: Re: ed2k links support (with bb-codes)
Post by: ë®â§e® on August 08, 2011, 04:34:00 PM
when it is updated for smf 2?