其他类别下载排行
最近更新源码
- 动易转DEDECMS程序
- PHPGEN代码生成系统
- PHPSQL数据库系统 v2007
- PHP读取excel文件的源代码
- PHP在线解压缩的程序
- ThinkPHP v1.0.0RC1
- FleaPHP 1.0.70.947 (开源 PHP开发框架)
- PHP Calendar Basic v2.2汉化版 (简单日历备忘录程序)
- 钢笔手写体生成工具(PHP) v1.0
- PHP 在线生成 favicon.ico
- Release Easy 2 Home Edition(RE2网站在线管理PHP文本)
- Vanlic RSS Log 开源RSS采集系统 v1.1
- phpMyEdit v5.7
- 在线CSS压缩与优化工具CssCompressor v1.3汉化版
- 网站不良信息检查系统
编辑推荐
BT种子信息插件 For Discuz 5.0
-
软件简介:
- 免费电子书下载
- 非常安全的浏览器
- 网站通过Google赚取美金
数据库升级: None
缺陷和不足:
1.发帖时候如果同时出现两个以上的[bt]将只能解释第一个,
但一直没写出其中的正则替换多个标签。
2.采用了远程读取和mb_string或iconv及对照表形式进行了UTF-8的转换
效率可能有点问题,而且很少有虚拟主机的伺服器能支持mb_string或iconv。
3.水平有限,代码很凌乱,参考了不少程序的函数,在此不说了,看你能看出几个。
打开discuzcode.func.php,在最后一行(大概320)后添加下列代码:
/*-------------------torrent plug----------------
author:blue2004
QQ:80392625
HomePage:http://www.pearphp.com/
Email:pearphp#gmail.com
Date:2007-2-3
------------------------------------------------*/
function convert_encoding($str, $from, $to)
{
if (function_exists('mb_convert_encoding')) {
$str = mb_convert_encoding($str, $to, $from);
} elseif (function_exists('iconv')) {
$str = iconv($from, $to, $str);
} else {
include_once(DISCUZ_ROOT.'./include/functions_encoding.php');
$encode= new Encoding();
$str = $encode->EncodeString($str, $from, $to);
}
return $str;
}
function iif($expression, $returntrue, $returnfalse = '')
{
return ($expression ? $returntrue : $returnfalse);
}
/**
* Formats a number with user's own decimal and thousands chars
*
* @param mixed Number to be formatted: integer / 8MB / 16 GB / 6.0 KB / 3M / 5K / ETC
* @param integer Number of decimal places to display
* @param boolean Special case for byte-based numbers
*
* @return mixed The formatted number
*/
function vb_number_format($number, $decimals = 0, $bytesize = false)
{
$type = '';
if (empty($number))
{
return 0;
}
else if (preg_match('#^(\d+(?:\.\d+)?)(?>\s*)([mkg])b?$#i', trim($number), $matches))
{
switch(strtolower($matches[2]))
{
case 'g':
$number = $matches[1] * 1073741824;
break;
case 'm':
$number = $matches[1] * 1048576;
break;
case 'k':
$number = $matches[1] * 1024;
break;
default:
$number = $matches[1] * 1;
}
}
if ($bytesize)
{
if ($number >= 1073741824)
{
$number = $number / 1073741824;
$decimals = 2;
$type = "G";
}
else if ($number >= 1048576)
{
$number = $number / 1048576;
$decimals = 2;
$type = "MB";
}
else if ($number >= 1024)
{
$number = $number / 1024;
$decimals = 1;
$type = "KB";
}
else
{
$decimals = 0;
$type = " bytes";
}
}
return str_replace('_', ' ', number_format($number, $decimals)) . $type;
}
// {{{ bt UBB()
/**
*get bt tag
*/
function tag_bt($info){
$info = stripslashes($info);
preg_match_all("/\[bt\](.+?)\[\/bt\]/is", $info, $matches);
return $matches[1];
}
// {{{ fetchContent()
/**
* Fetch the remote content.
* @param string url of the page
* @param string get the http header?
* @return string HTML of the page
*/
function fetchContent($url, $getHeader = false)
{
$content = "";
if (ini_get('allow_url_fopen') && !$getHeader) {
//ByFile
$handle = @fopen($url,"r");
if(!$handle){
return false;
}
while($buffer = fgets($handle, 4096)) {
$content .= $buffer;
}
fclose($handle);
return $content;
} elseif (function_exists('curl_init')) {
//ByCurl
$handle = curl_init();
curl_setopt ($handle, CURLOPT_URL, $url);
curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt ($handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($handle, CURLOPT_FOLLOWLOCATION, 0);
if ($getHeader) {
curl_setopt ($handle, CURLOPT_HEADER, 1);
curl_setopt ($handle, CURLOPT_NOBODY, 1);
}
$content = curl_exec($handle);
curl_close($handle);
return $content;
} elseif (function_exists('fsockopen')) {
//BySocket
if (!($pos = strpos($url, '://'))) {
return false;
}
$host = substr($url, $pos+3, strpos($url, '/', $pos+3) - $pos - 3);
$uri = substr($url, strpos($url, '/', $pos+3));
$request = "GET " . $uri . " HTTP/1.0\r\n"
."Host: " . $host . "\r\n"
."Accept: */*\r\n"
."User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)\r\n"
."\r\n";
$handle = @fsockopen($host, 80, $errno, $errstr, 30);
if (!$handle) {
return false;
}
@fputs($handle, $request);
while (!feof($handle)){
$content .= fgets($handle, 4096);
}
fclose($handle);
$separator = strpos($content, "\r\n\r\n");
if($getHeader) {
if($separator === false) {
return false;
} else {
return substr($content, 0, $separator);
}
} else {
if($separator === false) {
return $content;
} else {
return substr($content, $separator + 4);
}
}
} else {
return false;
}
}
function info_bt($message){
$array =tag_bt($message);
if (is_array($array)) {
#echo count($array);
#foreach ($array as $key => $value) {
#echo $array[$key];
@set_time_limit(10);
$content = fetchContent($array['0']);
if (!empty($content)) {
include_once DISCUZ_ROOT.'./include/bencode.php';
$bencode = new BEncodeLib();
$torrent = $bencode->bdecode($content);
if (is_array($torrent)) {
#print_r($torrent);
if (is_array($torrent['announce-list'])) {
foreach ($torrent['announce-list'] as $key => $value) {
$announce .= $torrent['announce-list'][$key][0] . '\n';
}
} else {
$announce = $torrent['announce'];
}
$created_by = $torrent['created by'];
$creation_date =$torrent['creation date'];
$encoding = $torrent['encoding'];
#$codepage= $torrent['codepage'];#error
$name = convert_encoding($torrent['info']['name.utf-8'],$from="UTF-8", $to="GBK");
#$length = $torrent['info']['length'];#error
#$pieces =$torrent['info']['pieces'];#error
$piece_length =$torrent['info']['piece length'];
$publisher =convert_encoding($torrent['info']['publisher.utf-8'],$from="UTF-8", $to="GBK");
$publisher_url =$torrent['info']['publisher-url.utf-8'];
$bt_head ="[url=$array[0]]下载种子文件[/url]\n[b]Tracker Url:[/b]\n".$announce."[b]软件:[/b]".$created_by."\n[b]编码:[/b]".$encoding."\n[b]名称:[/b]".$name."\n[b]块长度:[/b]".$piece_length."\n[b]发布人:[/b]".$publisher."\n[b]站点:[/b]".$publisher_url."\n";
#*********nodes
if (is_array($torrent['nodes'])){
foreach ($torrent['nodes'] as $key => $value) {
$nodes .= $torrent['nodes'][$key][0] . ':' . $torrent['nodes'][$key][1] . "\n";
}
}else{
$nodes = $torrent['nodes'];
}
#*********
#---------files
if (is_array($torrent['info']['files'])) {
foreach ($torrent['info']['files'] as $key => $value) {
if($torrent['info']['files'][$key]['path']) {
$files .= iif(is_array($torrent['info']['files'][$key]['path']), implode('/', $torrent['info']['files'][$key]['path']), $torrent['info']['files'][$key]['path']) . ' (' . vb_number_format($torrent['info']['files'][$key]['length'], 1, true) . ') \n';
} else {
$files .= iif(is_array($torrent['info']['files'][$key]['path.utf-8']), implode('/', $torrent['info']['files'][$key]['path.utf-8']), $torrent['info']['files'][$key]['path.utf-8']) . ' (' . vb_number_format($torrent['info']['files'][$key]['length'], 1, true) . ') \n';
}
}
}
#----------
$info =$bt_head."[b]节点:[/b]\n".$nodes."[b]种子文件:[/b]\n".$files;
}
}
#}
return preg_replace("/\[bt\](.+?)\[\/bt\]/is",$info, $message);
} else {
return $message; //$infos =info_bt($message);
}
}
在newthread.inc.php搜索
$pinvisible = $modnewthreads ? -2 : 0;
在下面添加一句:
$message =info_bt($message);
上传文件,覆盖到include目录

