- Kod: Tümünü seç
##############################################################
## Mod Title: ed2k (BBcode)
## Mod Author: [ Oki/Mozes/Meithar ]
## Toparlayan: WEBMASTER - http://www.vatan-board.net.tc
## Mod Description: a little comfort URL Query based on Javascript
## Mod Version: 1.1.1
##
## Installation Level: Easy
## Installation Time: 5 Minutes
## Files To Edit: includes/bbcode.php
## viewtopic.php
##
## Included Files: n/a
##############################################################
## Before Adding This Mod To Your Forum, You Should Back Up All Files Related To This Mod
##############################################################
#
#-----[ AC ]-----
#
bbcode.php
#
#-----[ BUL ]-----
#
$bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['url4']);
#
#-----[ ARKASINA EKLE ]-----
#
// 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
#
#-----[ BUL ]-----
#
// phpBB code.. (no xxxx:// prefix).
$patterns[4] = "#\[url=([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si";
$replacements[4] = $bbcode_tpl['url4'];
#
#-----[ ARKASINA EKLE ]-----
#
// 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
#
#-----[ BUL ]-----
#
function make_clickable($text)
{
// pad it with a space so we can match things at the start of the 1st line.
$ret = ' ' . $text;
// 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]+?://[^ \"\n\r\t<]*)#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)\.[^ \"\t\n\r<]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
// matches an email@domain type address at the start of a line, or after a space.
// 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);
}
#
#-----[ BUNUNLA DEGISTIR ]-----
#
function make_clickable($text)
{
// pad it with a space so we can match things at the start of the 1st line.
$ret = ' ' . $text;
// ed2k file links: (by Meithar)
// ed2k://|file|fileName|fileSize|fileHash|(optional params)|(optional params)|etc|
$ret = preg_replace("#(^|(?<=[^\w\"']))(ed2k://\|file\|([^\\/\|:<>\*\?\"]+?)\|(\d+?)\|([a-f0-9]{32})\|(.*?)/?)(?![\"'])(?=([,\.]*?[\s<\[])|[,\.]*?$)#i", "<a href=\"\\2\">\\3</a>", $ret);
// ed2k server links: (by Meithar)
// ed2k://|server|serverIP|serverPort
$ret = preg_replace("#(^|(?<=[^\w\"']))(ed2k://\|server\|([\d\.]+?)\|(\d+?)\|/?)#i", "<a href=\"\\2\">\\3:\\4</a>", $ret);
// 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]+?://[^ \|\"\n\r\t<]+)#i", "\\1<a href=\"\\2\">\\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)\.[^ \"\t\n\r<]+)#i", "\\1<a href=\"http://\\2\">\\2</a>", $ret);
// matches an email@domain type address at the start of a line, or after a space.
// 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);
}
#
#-----[ BUL ]-----
#
// 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);
}
#
#-----[ ARKASINA EKLE ]-----
#
/**
* 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> ";
$t_ed2kinsert .= "<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);
}
#
#-----[ AC ]-----
#
viewtopic.php
#
#-----[ BUL ]-----
#
$message = make_clickable($message);
#
#-----[ ÖNÜNE EKLE ]-----
#
$message = make_addalled2k_link($message,$postrow[$i]['post_id']); // ed2k link and add all
#-----[ BÜTÜN DOSYALARI KAPAT ]-----