torrent org php,torrentrss.php

require "include/bittorrent.php";

dbconn();

function hex_esc($matches) {

return sprintf("%02x", ord($matches[0]));

}

$dllink = false;

$passkey = $_GET['passkey'];

$where = "";

if ($passkey){

$res = sql_query("SELECT id, enabled, parked FROM users WHERE passkey=". sqlesc($passkey)." LIMIT 1");

$user = mysql_fetch_array($res);

if (!$user)

die("invalid passkey");

elseif ($user['enabled'] == 'no' || $user['parked'] == 'yes')

die("account disabed or parked");

elseif ($_GET['linktype'] == 'dl')

$dllink = true;

$inclbookmarked=0+$_GET['inclbookmarked'];

if($inclbookmarked == 1)

{

$bookmarkarray = return_torrent_bookmark_array($user['id']);

if ($bookmarkarray){

$whereidin = implode(",", $bookmarkarray);

$where .= ($where ? " AND " : "") . "torrents.id IN(" . $whereidin . ")";

}

}

}

$searchstr = mysql_real_escape_string(trim($_GET["search"]));

if (empty($searchstr))

unset($searchstr);

if (isset($searchstr)){

$search_mode = 0 + $_GET["search_mode"];

if (!in_array($search_mode,array(0,1,2)))

{

$search_mode = 0;

}

switch ($search_mode)

{

case 0:// AND, OR

case 1:

$searchstr = str_replace(".", " ", $searchstr);

$searchstr_exploded = explode(" ", $searchstr);

$searchstr_exploded_count= 0;

foreach ($searchstr_exploded as $searchstr_element)

{

$searchstr_element = trim($searchstr_element);// furthur trim to ensure that multi space seperated words still work

$searchstr_exploded_count++;

if ($searchstr_exploded_count > 10)// maximum 10 keywords

break;

$like_expression_array[] = " LIKE '%" . $searchstr_element. "%'";

}

break;

case 2:// exact

{

$like_expression_array[] = " LIKE '%" . $searchstr. "%'";

break;

}

}

$ANDOR = ($search_mode == 0 ? " AND " : " OR ");// only affects mode 0 and mode 1

foreach ($like_expression_array as &$like_expression_array_element)

$like_expression_array_element = "(torrents.name" . $like_expression_array_element.($_GET['ismalldescr'] ? " OR torrents.small_descr". $like_expression_array_element : "").")";

$wherea[] = implode($ANDOR, $like_expression_array);

$where .= ($where ? " AND " : "") . implode(" AND ", $wherea);

}

$limit = "";

$startindex = 0+$_GET['startindex'];

if ($startindex)

$limit .= $startindex.", ";

$showrows = 0+$_GET['rows'];

if($showrows < 1 || $showrows > 50)

$showrows = 10;

$limit .= $showrows;

function get_where($tablename = "sources", $itemname = "source", $getname = "sou")

{

global $where;

$items = searchbox_item_list($tablename);

$whereitemina = array();

foreach ($items as $item)

{

if ($_GET[$getname.$item[id]])

{

$whereitemina[] = $item[id];

}

}

if (count($whereitemina) >= 1){

$whereitemin = implode(",",$whereitemina);

$where .= ($where ? " AND " : "") . $itemname." IN(" . $whereitemin . ")";

}

}

get_where("categories", "category", "cat");

get_where("sources", "source", "sou");

get_where("media", "medium", "med");

get_where("codecs", "codec", "cod");

get_where("standards", "standard", "sta");

get_where("processings", "processing", "pro");

get_where("teams", "team", "tea");

get_where("audiocodecs", "audiocodec", "aud");

if ($where)

$where = "WHERE ".$where;

$query = "SELECT torrents.id, torrents.category, torrents.name, torrents.small_descr, torrents.descr, torrents.info_hash, torrents.size, torrents.added, torrents.anonymous, users.username AS username, categories.id AS cat_id, categories.name AS cat_name FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where ORDER BY torrents.added DESC LIMIT $limit";

$res = sql_query($query) or die(mysql_error());

$url = get_protocol_prefix().$BASEURL;

$year = substr($datefounded, 0, 4);

$yearfounded = ($year ? $year : 2007);

$copyright = "Copyright (c) ".$SITENAME." ".(date("Y") != $yearfounded ? $yearfounded."-" : "").date("Y").", all rights reserved";

header ("Content-type: text/xml");

print("<?xml version=\"1.0\" encoding=\"utf-8\"?>");

//The commented version passed feed validator at http://www.feedvalidator.org

/*print('

');*/

print('

');

print('

' . addslashes($SITENAME.' Torrents'). '

zh-cn

'.$copyright.'

'.$SITEEMAIL.' ('.$SITENAME.' Admin)

'.$SITEEMAIL.' ('.$SITENAME.' Webmaster)

'.date('r').'

'.PROJECTNAME.' RSS Generator

60

' . addslashes($SITENAME.' Torrents') . '

100

100

' . addslashes($SITENAME.' Torrents') . '

');

/*print('

');*/

print('

');

while ($row = mysql_fetch_array($res))

{

$title = "";

if ($row['anonymous'] == 'yes')

$author = 'anonymous';

else $author = $row['username'];

$itemurl = $url."/details.php?id=".$row['id'];

if ($dllink)

$itemdlurl = $url."/download.php?id=".$row['id']."&passkey=".rawurlencode($passkey);

else $itemdlurl = $url."/download.php?id=".$row['id'];

if ($_GET['icat']) $title .= "[".$row['cat_name']."]";

$title .= $row['name'];

if ($_GET['ismalldescr'] && $row['small_descr']) $title .= "[".$row['small_descr']."]";

if ($_GET['isize']) $title .= "[".mksize($row['size'])."]";

if ($_GET['iuplder']) $title .= "[".$author."]";

$content = format_comment($row['descr'], true, false, false, false);

print('

'.$itemurl.'

');

//print(''.$author.'');

print(''.$author.'@'.$_SERVER['HTTP_HOST'].' ('.$author.')');

print('

'.$row['cat_name'].'

'.preg_replace_callback('/./s', 'hex_esc', hash_pad($row['info_hash'])).'

'.date('r',strtotime($row['added'])).'

');

}

print('

');

?>

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值