<?php
// Using Tracker Adress: -> "http://torrent.tracker.durukanbal.com/"
ini_set ( 'display_errors', FALSE );
ini_set ( 'display_startup_errors', FALSE );
// ini_set ( 'display_errors', TRUE );
// ini_set ( 'display_startup_errors', TRUE );
// error_reporting ( E_ALL );
header ( "content-type: text/plain" );
global $db;
$db = new PDO ( 'mysql:host=localhost;dbname=DataBaseName', 'UserName', 'Password' );
global $info_hash;
$info_hash = urldecode ( $_GET['info_hash'] ?? '' );
$info_hash = bin2hexsafe ( $info_hash );
global $peer_id;
$peer_id = urldecode ( $_GET['peer_id'] ?? '' );
$peer_id = bin2hexsafe ( $peer_id );
global $ip;
$ip = $_SERVER['REMOTE_ADDR'];
global $port;
$port = $_GET['port'] ?? 0;
global $uploaded;
$uploaded = $_GET['uploaded'] ?? 0;
global $downloaded;
$downloaded = $_GET['downloaded'] ?? 0;
global $left;
$left = $_GET['left'] ?? 0;
if
(
isset ( $info_hash ) === TRUE
AND
isset ( $peer_id ) === TRUE
AND
isset ( $port ) === TRUE
)
{
if
(
strlen ( $info_hash ) >= 1
AND
strlen ( $peer_id ) >= 1
AND
intval ( $port ) >= 0 AND intval ( $port ) <= 65535
)
{
RemoveOldData();
echo QueryRecored();
}
else
{
echo "Bad Request !";
}
}
else
{
echo "Bad Request !";
}
function bencode ( $data )
{
if ( is_string ( $data ) )
{
return strlen ( $data ) . ':' . $data;
}
else if ( is_int ( $data ) )
{
return 'i' . $data . 'e';
}
else if ( is_array ( $data ) )
{
if ( array_values ( $data ) === $data )
{
return 'l' . implode ( '', array_map ( 'bencode', $data ) ) . 'e';
}
else
{
$encoded_elements = array();
foreach ( $data as $key => $value )
{
$encoded_elements[] = bencode ( $key );
$encoded_elements[] = bencode ( $value );
}
return 'd' . implode ( '', $encoded_elements ) . 'e';
}
}
return NULL;
} // Function bencode
function bin2hexsafe ( $hexString )
{
if ( ctype_xdigit ( $hexString ) )
{
return $hexString;
}
else
{
return bin2hex ( $hexString );
}
}
function Response ( $info_hash )
{
global $db;
$query =
'
SELECT
peer_id,
ip,
port
FROM
peers
WHERE
info_hash = ?
';
$stmt = $db->prepare ( $query );
$stmt->bindParam ( 1, $info_hash, PDO::PARAM_STR );
$stmt->execute();
$peers = $stmt->fetchAll ( PDO::FETCH_ASSOC );
$response = array
(
'interval' => 1800,
// 'min interval' => 900, // Ekledim
// 'complete' => 0, // Ekledim
// 'incomplete' => 2, // Ekledim
// 'peers' => array ()
'peers' => array_map
(
function ( $peer )
{
return array
(
'peer id' => hex2bin ( $peer['peer_id'] ),
'ip' => $peer['ip'],
'port' => intval ( $peer['port'] )
);
},
$peers
)
);
/*
foreach ( $peers AS $index => $data )
{
array_push
(
$response["peers"], array
(
'peer id' => hex2bin ( $data['peer_id'] ),
'ip' => $data['ip'],
'port' => intval ( $data['port'] )
)
);
}
*/
return bencode ( $response );
}
function RemoveOldData ()
{
global $db;
$query = $db->query
(
"
SELECT NOW() AS 'current_time'
"
);
$result = $query->fetch ( PDO::FETCH_ASSOC );
$dbTime = new DateTime ( $result['current_time'] );
$dbTime->format ( 'Y-m-d H:i:s' );
$timeout = clone $dbTime;
// $timeout = new DateTime();
$timeout->modify ( '-1 hours' ); // 7 + 2 = 9 // 7 sabit
$query =
'
DELETE FROM
peers
WHERE
updated_at < ?
';
$stmt = $db->prepare ( $query );
$stmt->execute
(
array
(
$timeout->format ( 'Y-m-d H:i:s' )
)
);
} // Function RemoveOldData
function QueryRecored ()
{
global $db;
global $info_hash;
global $peer_id;
global $ip;
global $port;
global $uploaded;
global $downloaded;
global $left;
$query =
'
INSERT INTO peers
(
info_hash,
peer_id,
ip,
port,
uploaded,
downloaded,
remaining
)
VALUES
(
:info_hash,
:peer_id,
:ip1,
:port1,
:uploaded1,
:downloaded1,
:left1
) ON DUPLICATE KEY UPDATE
ip = :ip2,
port = :port2,
uploaded = :uploaded2,
downloaded = :downloaded2,
remaining = :left2
';
$stmt = $db->prepare ( $query );
// Insert
$stmt->bindParam ( ':info_hash', $info_hash, PDO::PARAM_STR );
$stmt->bindParam ( ':peer_id', $peer_id, PDO::PARAM_STR );
$stmt->bindParam ( ':ip1', $ip, PDO::PARAM_STR );
$stmt->bindParam ( ':port1', $port, PDO::PARAM_INT );
$stmt->bindParam ( ':uploaded1', $uploaded, PDO::PARAM_INT );
$stmt->bindParam ( ':downloaded1', $downloaded, PDO::PARAM_INT );
$stmt->bindParam ( ':left1', $left, PDO::PARAM_INT );
// Update
$stmt->bindParam ( ':ip2', $ip, PDO::PARAM_STR );
$stmt->bindParam ( ':port2', $port, PDO::PARAM_INT );
$stmt->bindParam ( ':uploaded2', $uploaded, PDO::PARAM_INT );
$stmt->bindParam ( ':downloaded2', $downloaded, PDO::PARAM_INT );
$stmt->bindParam ( ':left2', $left, PDO::PARAM_INT );
$stmt->execute();
return Response ( $info_hash );
}
?>
-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Oct 17, 2023 at 03:21 PM
-- Server version: 8.0.34
-- PHP Version: 8.1.16
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `durukanbal_torrent_tracker`
--
-- --------------------------------------------------------
--
-- Table structure for table `peers`
--
CREATE TABLE `peers` (
`info_hash` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`peer_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`ip` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`port` int NOT NULL,
`uploaded` bigint NOT NULL,
`downloaded` bigint NOT NULL,
`remaining` bigint NOT NULL,
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `peers`
--
ALTER TABLE `peers`
ADD PRIMARY KEY (`info_hash`,`peer_id`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
145 Comments
warkoptoto2 · 02/12/2023 at 12:25
I think the admin of this site is genuinely working hard in favor of his website, since here every stuff is quality based data.
qq333bet · 02/12/2023 at 12:48
This site truly has all of the information and facts I needed concerning this subject and didn’t know who to ask.
winlive4d · 02/12/2023 at 14:31
I think the admin of this site is genuinely working hard in favor of his website, since here every stuff is quality based data.
udintogel-login · 02/12/2023 at 17:02
I think the admin of this site is genuinely working hard in favor of his website, since here every stuff is quality based data.
oddigo · 02/12/2023 at 19:07
I think the admin of this site is genuinely working hard in favor of his website, since here every stuff is quality based data.
apibet · 02/12/2023 at 19:23
I think the admin of this site is genuinely working hard in favor of his website, since here every stuff is quality based data.
bulantogel · 02/12/2023 at 19:52
Hello everybody, here every person is sharing these experience, therefore it’s good to read this web site, and I used to go to see this blog daily.
surgaplay · 02/12/2023 at 20:14
This site truly has all of the information and facts I needed concerning this subject and didn’t know who to ask.
sule-toto · 03/12/2023 at 10:59
I do agree with all of the concepts you’ve introduced for your post. They are very convincing and can certainly work. Still, the posts are too brief for starters. May just you please prolong them a little from subsequent time? Thanks for the post.
kratonbet · 03/12/2023 at 10:59
Your style is very unique compared to other folks I have read stuff from. Many thanks for posting when you’ve got the opportunity, Guess I’ll just book mark this blog.
api88 · 03/12/2023 at 11:06
Hey there! This is kind of off topic but I need some help from an established blog. Is it very difficult to set up your own blog? I’m not very techincal but I can figure things out pretty fast. I’m thinking about making my own but I’m not sure where to begin. Do you have any ideas or suggestions? Many thanks
angkaraja · 03/12/2023 at 11:18
Your style is very unique compared to other folks I have read stuff from. Many thanks for posting when you’ve got the opportunity, Guess I’ll just book mark this blog.
jayajp · 03/12/2023 at 12:30
I am no longer certain where you’re getting your information, however good topic. I must spend some time studying more or figuring out more. Thanks for wonderful information I used tobe looking for this info for my mission.
cerah88 · 03/12/2023 at 13:23
Hi, i believe that i noticed you visited my weblog thus i came to return the prefer?.I’m attempting to to find issues to improve my site!I assume its adequate to use some of your ideas!!
merdeka138 · 03/12/2023 at 14:26
I was recommended this website by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my difficulty You’re wonderful! Thanks!
mawartoto · 03/12/2023 at 16:55
Hi, i believe that i noticed you visited my weblog thus i came to return the prefer?.I’m attempting to to find issues to improve my site!I assume its adequate to use some of your ideas!!
angkaraja · 03/12/2023 at 18:14
I was recommended this website by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my difficulty You’re wonderful! Thanks!
live-sdy · 03/12/2023 at 18:16
Hello everybody, here every person is sharing these experience, therefore it’s good to read this web site, and I used to go to see this blog daily.
data-macau-5d · 03/12/2023 at 18:42
This site truly has all of the information and facts I needed concerning this subject and didn’t know who to ask.
mega338 · 03/12/2023 at 18:50
Hello everybody, here every person is sharing these experience, therefore it’s good to read this web site, and I used to go to see this blog daily.
keraton4d · 03/12/2023 at 19:09
Hey there! This is kind of off topic but I need some help from an established blog. Is it very difficult to set up your own blog? I’m not very techincal but I can figure things out pretty fast. I’m thinking about making my own but I’m not sure where to begin. Do you have any ideas or suggestions? Many thanks
mawartoto · 03/12/2023 at 19:12
I think the admin of this site is genuinely working hard in favor of his website, since here every stuff is quality based data.
setantoto · 03/12/2023 at 19:41
This site truly has all of the information and facts I needed concerning this subject and didn’t know who to ask.
animeindo · 03/12/2023 at 19:51
Wonderful goods from you, man. I’ve understand your stuff previous to and you’re just too fantastic. I really like what you’ve acquired here, really like what you’re saying and the way in which you say it. You make it entertaining and you still take care of to keep it smart. I can’t wait to read much more from you. This is actually a tremendous site.
roma77 · 04/12/2023 at 07:39
Wonderful goods from you, man. I’ve understand your stuff previous to and you’re just too fantastic. I really like what you’ve acquired here, really like what you’re saying and the way in which you say it. You make it entertaining and you still take care of to keep it smart. I can’t wait to read much more from you. This is actually a tremendous site.
roma77 · 04/12/2023 at 07:45
I do agree with all of the concepts you’ve introduced for your post. They are very convincing and can certainly work. Still, the posts are too brief for starters. May just you please prolong them a little from subsequent time? Thanks for the post.
omtogel · 04/12/2023 at 08:08
Hi, i believe that i noticed you visited my weblog thus i came to return the prefer?.I’m attempting to to find issues to improve my site!I assume its adequate to use some of your ideas!!
live-draw-sdy · 04/12/2023 at 13:20
I do agree with all of the concepts you’ve introduced for your post. They are very convincing and can certainly work. Still, the posts are too brief for starters. May just you please prolong them a little from subsequent time? Thanks for the post.
paito-warna-sdy · 04/12/2023 at 15:45
I was recommended this website by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my difficulty You’re wonderful! Thanks!
mawartoto · 04/12/2023 at 16:39
I am no longer certain where you’re getting your information, however good topic. I must spend some time studying more or figuring out more. Thanks for wonderful information I used tobe looking for this info for my mission.
animeindo · 04/12/2023 at 17:05
This site truly has all of the information and facts I needed concerning this subject and didn’t know who to ask.
udintogel-login · 04/12/2023 at 20:15
Wonderful goods from you, man. I’ve understand your stuff previous to and you’re just too fantastic. I really like what you’ve acquired here, really like what you’re saying and the way in which you say it. You make it entertaining and you still take care of to keep it smart. I can’t wait to read much more from you. This is actually a tremendous site.
paito-warna-sydney · 04/12/2023 at 20:17
Wonderful goods from you, man. I’ve understand your stuff previous to and you’re just too fantastic. I really like what you’ve acquired here, really like what you’re saying and the way in which you say it. You make it entertaining and you still take care of to keep it smart. I can’t wait to read much more from you. This is actually a tremendous site.
dauntogel · 04/12/2023 at 21:45
This site truly has all of the information and facts I needed concerning this subject and didn’t know who to ask.
paito-warna-sdy · 04/12/2023 at 21:47
Hello everybody, here every person is sharing these experience, therefore it’s good to read this web site, and I used to go to see this blog daily.
ayuslot · 04/12/2023 at 22:13
I do agree with all of the concepts you’ve introduced for your post. They are very convincing and can certainly work. Still, the posts are too brief for starters. May just you please prolong them a little from subsequent time? Thanks for the post.
skintoto · 04/12/2023 at 22:39
Your style is very unique compared to other folks I have read stuff from. Many thanks for posting when you’ve got the opportunity, Guess I’ll just book mark this blog.
skintoto · 04/12/2023 at 22:42
I think the admin of this site is genuinely working hard in favor of his website, since here every stuff is quality based data.
belijitu · 04/12/2023 at 22:46
I do agree with all of the concepts you’ve introduced for your post. They are very convincing and can certainly work. Still, the posts are too brief for starters. May just you please prolong them a little from subsequent time? Thanks for the post.
catur777 · 04/12/2023 at 23:15
I am no longer certain where you’re getting your information, however good topic. I must spend some time studying more or figuring out more. Thanks for wonderful information I used tobe looking for this info for my mission.
animeindo · 04/12/2023 at 23:24
Hey there! This is kind of off topic but I need some help from an established blog. Is it very difficult to set up your own blog? I’m not very techincal but I can figure things out pretty fast. I’m thinking about making my own but I’m not sure where to begin. Do you have any ideas or suggestions? Many thanks
jabartoto · 04/12/2023 at 23:27
This site truly has all of the information and facts I needed concerning this subject and didn’t know who to ask.
pos4d · 04/12/2023 at 23:37
Wonderful goods from you, man. I’ve understand your stuff previous to and you’re just too fantastic. I really like what you’ve acquired here, really like what you’re saying and the way in which you say it. You make it entertaining and you still take care of to keep it smart. I can’t wait to read much more from you. This is actually a tremendous site.
bantogel · 05/12/2023 at 00:07
Your style is very unique compared to other folks I have read stuff from. Many thanks for posting when you’ve got the opportunity, Guess I’ll just book mark this blog.
indotogel · 05/12/2023 at 00:17
Hi, i believe that i noticed you visited my weblog thus i came to return the prefer?.I’m attempting to to find issues to improve my site!I assume its adequate to use some of your ideas!!