Hmm, i see only one changed line, it's
Code:
$selfwhere = 'fid = ' . $torrentdata['fid'] . ' AND peer_id = ' . hash_where('peer_id', $peer_id);
it was
Code:
$selfwhere = 'fid = ' . $torrentdata['fid'] . ' AND ' . hash_where('peer_id', $peer_id);
but this "fix" not correct and if you use it, you'll broke announce.php, because function hash_where return table name which added with this "fix"