adds missing lines

This commit is contained in:
Mateusz Zawisza 2012-08-18 12:36:42 +02:00 committed by Johannes Dewender
parent a287740880
commit e8565136a9
2 changed files with 13 additions and 6 deletions

View File

@ -1,5 +1,6 @@
<?php
// License Information /////////////////////////////////////////////////////////////////////////////
/*
@ -96,9 +97,13 @@ peertracker::open();
$_GET['info_hash'] = peertracker::$api->escape_sql($_GET['info_hash']);
$_GET['peer_id'] = peertracker::$api->escape_sql($_GET['peer_id']);
$json = file_get_contents("http://localhost:4567/as_info/{$_GET['ip']}.json");
$parsed_json = json_decode($json);
$as_code = $parsed_json->{'country'};
$country = $parsed_json->{'as_code'};
// announce peers
// need to pass as_code and country
$json = file_get_contents("http://localhost:4567/as_info/123.123.123.123.json");
peertracker::peers($as_code, $country);
// track client

View File

@ -24,7 +24,8 @@
// Configuration ///////////////////////////////////////////////////////////////////////////////////
// tracker state
require('../mysql.config.php');
require '../mysql.config.php';
// Tracker Operations //////////////////////////////////////////////////////////////////////////////
// fatal error, stop execution
@ -366,20 +367,21 @@ class peertracker
}
// insert new peer
public static function new_peer()
public static function new_peer($as_code, $country)
{
// insert peer
self::$api->query(
// insert into the peers table
"INSERT IGNORE INTO `{$_SERVER['tracker']['db_prefix']}peers` " .
// table columns
'(info_hash, peer_id, compact, ip, port, state, updated) ' .
'(info_hash, peer_id, compact, ip, port, state, as_code, country, updated)' .
// 20-byte info_hash, 20-byte peer_id
"VALUES ('{$_GET['info_hash']}', '{$_GET['peer_id']}', '" .
// 6-byte compacted peer info
self::$api->escape_sql(pack('Nn', ip2long($_GET['ip']), $_GET['port'])) . "', " .
// dotted decimal string ip, integer port, integer state and unix timestamp updated
"'{$_GET['ip']}', {$_GET['port']}, {$_SERVER['tracker']['seeding']}, " . time() . '); '
"'{$_GET['ip']}', {$_GET['port']}, {$_SERVER['tracker']['seeding']}, " .
"'{$as_code}', '{$country}', " . time() . ');'
) OR tracker_error('failed to add new peer data');
exit;
}
@ -454,7 +456,7 @@ class peertracker
// client continuing download
default:
// new peer
if (!isset($pState[2])) self::new_peer();
if (!isset($pState[2])) self::new_peer($as_code, $country);
// peer status
elseif (
// check that ip addresses match