Advertisement
Guest User

CurlyFries

a guest
Oct 21st, 2008
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <?php
  2. header('Content-type: text/plain');
  3.  
  4. $info_hash = $_GET['info_hash'];
  5. $peer_id = $_GET['peer_id'];
  6. $ip = $_SERVER['REMOTE_ADDR'];
  7. $port = intval($_GET['port']);
  8. $uploader = ($_GET['left'] == 0) ? 1 : 0;
  9. $event = in_array($_GET['event'], array('started', 'completed', 'stopped')) ? $_GET['event'] : 'empty';
  10.  
  11. mysql_connect('localhost', 'root', '');
  12. mysql_select_db('tracker');
  13.  
  14. switch ($event) {
  15. case 'started': mysql_query("INSERT INTO peers (info_hash, peer_id, uploader, ip, port) VALUES ('$info_hash', '$peer_id', $uploader, '$ip', $port);"); break;
  16. case 'completed': mysql_query("UPDATE peers SET uploader = 1 WHERE info_hash = '$info_hash' AND peer_id = '$peer_id';"); break;
  17. case 'stopped': mysql_query("DELETE FROM peers WHERE info_hash = '$info_hash' AND peer_id = '$peer_id';"); die();
  18. }
  19.  
  20. echo 'd8:intervali1800e5:peersl';
  21.  
  22. $res = mysql_query("SELECT peer_id, ip, port FROM peers WHERE info_hash = '$info_hash' AND peer_id != '$peer_id'" . ($uploader ? " AND uploader = 0" : "") . " ORDER BY RAND() LIMIT 25;");
  23. if (!mysql_num_rows($res)) die('ee');
  24.  
  25. while ($row = mysql_fetch_assoc($res))
  26. echo 'd7:peer id' . strlen($row['peer_id']) . ':' . $row['peer_id'] . '2:ip' . strlen($row['ip']) . ':' . $row['ip'] . '4:porti' . $row['port'] . 'ee';
  27.  
  28. die('ee');
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement