Skip to content

Instantly share code, notes, and snippets.

@nbrochu
Created September 10, 2009 04:48
Show Gist options
  • Save nbrochu/184310 to your computer and use it in GitHub Desktop.
Save nbrochu/184310 to your computer and use it in GitHub Desktop.
<?php
// Much simpler, no? I could be wrong, PHP isn't my primary language!
$data=bdecode('example.torrent');
$user=mysql_fetch_row(mysql_query("SELECT torrent_pass_version FROM xbt_users WHERE uid={$uid}"));
$torrent_pass_version=$user[0];
$config=mysql_fetch_row(mysql_query("SELECT value FROM xbt_config WHERE name='torrent_pass_private_key'"));
$torrent_pass_private_key=$config[0]
$passkey=sprintf('%08x%s', $uid, substr(sha1(sprintf('%s %d %d %s', $torrent_pass_private_key, $torrent_pass_version, $uid, pack('H*', $info_hash))), 0, 24));
$announce_url=parse_url("http://example:2710/announce");
$announce_url=sprintf('http://%s:%d/%s/announce', $announce_url['host'], $announce_url['port'], $passkey);
$data=bdecode('example.torrent');
$data['announce'] = $announce_url;
$new_data=bencode($data);
$new_size=strlen($new_data);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment