ZenoX |
21st March 2012 00:31 |
Adding 2nd Announce URL To download.php
Hey,
Can anyone help me with this?
All i basically want to do is add a 2nd announce url in download.php. So when members download a torrent from my site there are 2 announce's listed.
1. New announce.php (with passkey)
2. Old announce2.php (without passkey)
That way it will make sure that all older torrents will stay active and members will not have to re-download them as their client will update both announces.
I have this code, and it works in the client but the actual passkey doesn't show up..
Code:
require_once("include/bittorrent.php");
dbconn();
$id = (int)$_GET["id"];
$name = $_GET["name"];
if (!$id)
httperr();
$res = mysql_query("SELECT 1 FROM torrents WHERE id = $id");
$row = mysql_fetch_array($res);
$fn = "$torrent_dir/$id.torrent";
if (!$row || !is_file($fn) || !is_readable($fn))
httperr();
mysql_query("UPDATE torrents SET hits = hits + 1 WHERE id = $id");
require_once "include/benc.php";
if (strlen($CURUSER['passkey']) != 32) {
$CURUSER['passkey'] = md5($CURUSER['username'].get_date_time().$CURUSER['passhash']);
mysql_query("UPDATE users SET passkey='$CURUSER[passkey]' WHERE id=$CURUSER[id]");
}
$list = '';
$one[] = 'http://all4nothin.net/announce2.php';
$one[] = 'http://all4nothin.net/announce.php?passkey=$CURUSER[passkey]';
foreach($one as $x)
{
$list .= 'l'.strlen($x).':'.$x.'e';
}
$list = 'l'.$list.'e';
$list = bdec_list($list);
$dict = bdec_file($fn, (1024*1024));
$dict['value']['announce-list'] = $list;
$dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']).":".$dict['value']['announce']['value'];
$dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']);
$download_filename = ((strpos($torrent['filename'], '.torrent') === false) ? $torrent['filename'].'.torrent' : $torrent['filename']);
header ("Content-Disposition: attachment; filename=\"".$name."\"");
header ("Content-Type: application/x-bittorrent");
print(benc($dict));
?>
Thanks for any help you guys can give :)
|