adds updates to peertracker as info fetching

This commit is contained in:
Mateusz Zawisza 2012-08-18 22:34:41 +02:00 committed by Johannes Dewender
parent 33aaee6d4d
commit aef17086c7
2 changed files with 3 additions and 2 deletions

View File

@ -97,7 +97,7 @@ 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");
$json = file_get_contents("http://peertracker-as.local/as_info/{$_GET['ip']}.json");
$parsed_json = json_decode($json);
$as_code = $parsed_json->{'country'};
$country = $parsed_json->{'as_code'};

View File

@ -387,7 +387,7 @@ class peertracker
}
// full peer update
public static function update_peer()
public static function update_peer($as_code, $country)
{
// update peer
self::$api->query(
@ -397,6 +397,7 @@ class peertracker
"SET compact='" . self::$api->escape_sql(pack('Nn', ip2long($_GET['ip']), $_GET['port'])) .
// dotted decimal string ip, integer port
"', ip='{$_GET['ip']}', port={$_GET['port']}, " .
"'as_code='{$as_code}', country={$country}, " .
// integer state and unix timestamp updated
"state={$_SERVER['tracker']['seeding']}, updated=" . time() .
// that matches the given info_hash and peer_id