/** * Info * @param type $d * @return string */ static function benc_dict($d) { $s = "d"; $keys = array_keys($d); sort($keys); foreach ($keys as $k) { $v = $d[$k]; $s .= Bcode::benc_str($k); $s .= Bcode::benc($v); } $s .= "e"; return $s; }
if ($totpeers > $readsize) { $peer->setSort("RAND()"); $peer->setLimit($readsize); } $peer->select("peer_torrent = '" . $torrent->id . "'"); while ($peer->nextRecord()) { $peer->peer_id = str_pad($peer->peer_id, 20); if ($peer->peer_id === $data['peer_id']) { $self = $peer; continue; } $callback[] = "d" . Bcode::benc_str("ip") . Bcode::benc_str($peer->ip); if (!$_GET['no_peer_id']) { $callback[] = Bcode::benc_str("peer id") . Bcode::benc_str($peer->peer_id); } $callback[] = Bcode::benc_str("port") . "i" . $peer->port . "e" . "e"; } $callback[] = "ee"; $self_query = "peer_torrent = '" . $torrent_id . "' AND " . hash_where("peer_peer_id", $data['peer_id']); if (!isset($self)) { $db = new DB("peers"); $db->setCols($peer_cols); $db->setColPrefix("peer_"); $db->select($self_query); if ($db->numRows()) { $db->nextRecord(); $self = $db; $data['user_id'] = $self->userid; } } $torrent_query = array();