sibtracker/download.php
2019-05-18 13:46:03 +08:00

72 lines
2.7 KiB
PHP

<?php
@session_start ();
define ( 'DATALIFEENGINE', true );
define ( 'TORRENT_DIR', './uploads/torrents/' );
define( 'SYSTEM_DIR' , './system' );
@error_reporting (0);
require SYSTEM_DIR . '/data/config.php';
require_once SYSTEM_DIR . '/classes/mysql.php';
require_once SYSTEM_DIR . '/data/dbconfig.php';
require_once SYSTEM_DIR . '/modules/functions.php';
require_once SYSTEM_DIR . '/modules/sitelogin.php';
$user_group = $cache->get ( "usergroup" );
if (! $user_group) {
$user_group = array ();
$db->query ( "SELECT * FROM " . USERPREFIX . "_usergroups ORDER BY id ASC" );
while ( $row = $db->get_row () ) {
$user_group[$row['id']] = array ();
foreach ( $row as $key => $value ) {
$user_group[$row['id']][$key] = $value;
}}
$cache->set ( "usergroup", $user_group );
$db->free ();
}
if (! $is_logged) {$member_id['user_group'] = 5;}
if (! $user_group[$member_id['user_group']]['allow_files']) die ( "Access denied" );
$_SERVER['HTTP_REFERER'] = clean_url ( $_SERVER['HTTP_REFERER'] );
$_SERVER['HTTP_HOST'] = clean_url ( $_SERVER['HTTP_HOST'] );
if ($_SERVER['HTTP_HOST'] != $_SERVER['HTTP_REFERER']) {
@header ( 'Location: ' . $config['http_home_url'] );
die ( "Access denied!!!<br /><br />Please visit <a href=\"{$config['http_home_url']}\">{$config['http_home_url']}</a>" );
}
$id = intval ( $_REQUEST['id'] );
$d_time = time() + ($config['date_adjust'] * 60);
$row = $db->super_query ( "SELECT name, onserver, info_hash FROM " . PREFIX . "_torrents WHERE id ='$id'" );
if (! $row) die ( "Access denied" );
if(substr($row['name'], -8) == ".torrent") {
require_once( SYSTEM_DIR."/classes/torrent.class.php" );
$tr_file = TORRENT_DIR.$row['onserver'];
$torrent = new Torrent($tr_file);
if($error = $torrent->errors()){
}
else
{
$torrent->comment("http://".$_SERVER['HTTP_HOST']."/");
if (! $is_logged) {
$torrent->announce("http://".$_SERVER['HTTP_HOST'].":2710/announce"); //Äîáàâëÿåì äîïîëíèòåëüíûå àíîíñåðû, îñòàâëÿÿ óæå äîáàâëåííûå
} else {
$tpv = $member_id['torrent_pass_version'];
$tppk = $db->super_query("SELECT value FROM xbt_config WHERE name='torrent_pass_private_key'" );
$site_key = $tppk['value'];
$passkey = sprintf('%08x%s', $member_id['user_id'], substr(sha1(sprintf('%s %d %d %s', $site_key, $tpv, $member_id['user_id'], $row['info_hash'])), 0, 24));
$torrent->announce("http://".$_SERVER['HTTP_HOST'].":2710/{$passkey}/announce"); //Äîáàâëÿåì äîïîëíèòåëüíûå àíîíñåðû, îñòàâëÿÿ óæå äîáàâëåííûå
}
}} else die ( "Access denied" );
if ($config['files_count'] == "yes" and ! $file->range) $db->query ( "UPDATE " . PREFIX . "_torrents SET dcount=dcount+1 WHERE id ='$id'" );
$db->close ();
$torrent->send($row['name']);
?>