// Taken from php.net comments
function ip2long6($ipv6) {
$ip_n = inet_pton($ipv6);
$bits = 15; // 16 x 8 bit = 128bit
while ($bits >= 0) {
$bin = sprintf("%08b",(ord($ip_n[$bits])));
$ipv6long = $bin.$ipv6long;
$bits--;
}
return gmp_strval(gmp_init($ipv6long,2),10);
}
function long2ip6($ipv6long) {
$bin = gmp_strval(gmp_init($ipv6long,10),2);
if (strlen($bin) < 128) {
$pad = 128 - strlen($bin);
for ($i = 1; $i <= $pad; $i++) {
$bin = "0".$bin;
}
}
$bits = 0;
while ($bits <= 7) {
$bin_part = substr($bin,($bits*16),16);
$ipv6 .= dechex(bindec($bin_part)).":";
$bits++;
}
// compress
return inet_ntop(inet_pton(substr($ipv6,0,-1)));
} leech24:M-jay many many thxcheck linkhttps://torrenttrader.uk/topic?topicid=4745
/== Updated getip with validation
function getip()
{
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
return $ip;
}
foreach (array(
'HTTP_CLIENT_IP',
'HTTP_X_FORWARDED_FOR',
'HTTP_X_FORWARDED',
'HTTP_X_CLUSTER_CLIENT_IP',
'HTTP_FORWARDED_FOR',
'HTTP_FORWARDED',
'HTTP_CF_CONNECTING_IP',
'REMOTE_ADDR'
) as $key) {
if (array_key_exists($key, $_SERVER) === true) {
foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false) {
return $ip;
}
}
}
}
}
<?php
//
// ExtremlymTorrents v3.4
require_once("backend/functions.php");
require_once("backend/BDecode.php");
require_once("backend/parse.php"); //replace with parse later
require_once("backend/udptscraper.php");
dbconn();
$torrent_dir = $site_config["torrent_dir"];
//************ DO SOME "GET" STUFF BEFORE PAGE LAYOUT ***************
$id = (int) $_GET["id"];
$scrape = (int) $_GET["scrape"];
if (!is_valid_id($id))
show_error_msg("ERROR", T_("THATS_NOT_A_VALID_ID"), 1);
//GET ALL MYSQL VALUES FOR THIS TORRENT
$res = SQL_Query_exec("SELECT id , name, info_hash FROM torrents WHERE torrents.id = $id") or die(mysql_error());
while ($row = mysql_fetch_array($res))
{
$TorrentInfo = ParseTorrent("$site_config[torrent_dir]/$row[id].torrent");
$ann = $TorrentInfo[0];
$annlist = array();
if ($TorrentInfo[6])
{
foreach ($TorrentInfo[6] as $ann)
{
$annlist[] = $ann[0];
}
}
else
$annlist = array($ann);
$seeders = $leechers = $downloaded = null;
//echo "<br><font color=blue><b>LIVE STATUS</b></font><br>";
foreach ($annlist as $ann)
{
$tracker = explode("/", $ann);
$path = array_pop($tracker);
$oldpath = $path;
$path = str_replace("announce", "scrape", $path);
$tracker = implode("/", $tracker)."/".$path;
if ($oldpath == $path)
{
//echo "<br><b>$ann</b>: Scrape not supported.<br>";
continue;
}
// TPB's tracker is dead. Use openbittorrent instead
if ($openbittorrent_done)
continue;
if (preg_match("/thepiratebay.org/i", $tracker) || preg_match("/prq.to/", $tracker))
{
$tracker = "http://tracker.openbittorrent.com/scrape";
$openbittorrent_done = 1;
}
if(preg_match('%udp://([^:/]*)(?::([0-9]*))?(?:/)?%si', $tracker))
{
$udp=true;
try
{
$timeout = 5;
$udp= new udptscraper($timeout);
$stats=$udp->scrape($tracker,$row["info_hash"]);
foreach ($stats as $id=>$scrape)
{
$seeders += $scrape['seeders'];
$leechers += $scrape['leechers'];
$downloaded += $scrape['completed'];
}
}
catch(ScraperException $e)
{
// echo('<br>Error: ' . $e->getMessage() . "\n");
// echo('Connection error: ' . ($e->isConnectionError() ? 'yes' : 'no') . "\n");
}
}
else
{
$stats = torrent_scrape_url($tracker, $row["info_hash"]);
}
if ($stats['seeds'] != -1)
{
$seeders += $stats['seeds'];
$leechers += $stats['peers'];
$downloaded += $stats['downloaded'];
// echo "<br><b>$ann</b><br>";
echo "".($udp?$scrape['seeders']:$stats["seeds"])."<br>";
echo "".($udp?$scrape['leechers']:$stats["peers"])."<br>";
echo "".($udp?$scrape['completed']:$stats["downloaded"])."<br>";
SQL_Query_exec("UPDATE `announce` SET `online` = 'yes', `seeders` = $stats[seeds], `leechers` = $stats[peers], `times_completed` = $stats[downloaded] WHERE `url` = ".sqlesc($ann)." AND `torrent` = $row[id]");
}
else
{
// echo "<br><b>$ann</b>: <font color=red>Tracker timed out.</font><br>";
SQL_Query_exec("UPDATE `announce` SET `online` = 'no' WHERE `url` = ".sqlesc($ann)." AND `torrent` = $row[id]");
}
}
if ($seeders !== null)
{
// echo "<br><b><font color=red>Totals:</font></b><br>";
// echo "<b>Seeders: $seeders</b><br>";
// echo"<b>Leechers: $leechers</b><br>";
// echo "<b>Completed: $downloaded</b><br><br>";
SQL_Query_exec("UPDATE torrents SET leechers = '".$leechers."', seeders = '".$seeders."', times_completed = '".$downloaded."', last_action = '".get_date_time()."', visible = 'yes' WHERE id = '".$row['id']."'");
}
else
{
echo "<br><b><font color=red>All trackers are timed out.</font></b><br>";
SQL_Query_exec("UPDATE torrents SET last_action = '".get_date_time()."' WHERE id = '".$row['id']."'");
}
}
?>
//download box
echo "<iframe src='/scrapefile.php?id=$id' style='display: none;'></iframe>"; 
// TORRENT XXX MONTRER-CACHER BY GOLLUM
if($CURUSER["xxx_filter"] == 'yes'){
$ressa = mysql_query("SELECT * FROM xxx_filter");
while($datas = mysql_fetch_array($ressa)){
$wherea[] = "category != '".$datas["cat"]."' ";
}
}
// END TORRENT XXX MONTRER-CACHER BY GOLLUM// TORRENT XXX MONTRER-CACHER BY GOLLUM
if($CURUSER["xxx_filter"] == 'yes'){
$ressa = mysql_query("SELECT * FROM xxx_filter");
$wherex = "WHERE categories.id ";
while($datas = mysql_fetch_array($ressa)){
$wherex .= "AND id != '".$datas["cat"]."' ";
}
}
// END TORRENT XXX MONTRER-CACHER BY GOLLUM //===| Start Recommended Torrents |===//
///$rec = mysql_query("SELECT id, name, added, image1, seeders, leechers, times_completed FROM torrents WHERE banned ='no' AND visible='yes' AND recommendedx='yes' ORDER BY RAND() LIMIT 5 ");
///if (mysql_num_rows($rec) > 0) {
///print("<table align=center cellpadding=3 cellspacing=3 width=1000px border=0><tr>");
///while ($row2 = mysql_fetch_array($rec)) {
///$tor = $row2['0'];
///$altname = $row2['1'];
///$where = "WHERE banned = 'no' AND visible='yes' AND torrents.id='$tor'";
///$res = mysql_query("SELECT torrents.id, torrents.image1, torrents.image2, torrents.added, torrents.added, torrents.seeders, torrents.leechers, torrents.times_completed, categories.name AS cat_name FROM torrents LEFT JOIN categories ON torrents.category = categories.id $where");
///$row = mysql_fetch_array($res);
///$cat = $row['cat_name'];
///$img1 = "<a href=file.php?id=$row[id] target='_new'><div><img id='cover_img1' class='cover_img' border='0' src='uploads/images/$row[image1]' title=\"$altname | $cat\" width='210px' height='330px'></a></div>
///<div style='margin-top:10px; font-size:13px;'>
///<img src=images/check.png height='14' title='Completed' border=0><font color=#0080FF> <b>".$row['times_completed']."</b></font> |
///<img src=images/arrow_up.gif height='12' title='Seeders' border=0><font color=#00AA00><b>".$row['seeders']."</b></font> |
///<img src=images/arrow_down.gif height='12' title='Leechers' border=0><font color=#FF0000> <b>".$row['leechers']."</b></font>
///</div>";
///if ($row["image1"] != ""){
///print("<td align=center>".$img1."</td>");
///}else{
/// $img1 = "<a href=file.php?id=$row[id]'><img id='cover_img1' class='cover_img' border='0' src='/pic/uploadimage.jpg' title=\"$altname | $cat\" wiidth='210px' height='330px'></a>
///<div style='margin-top:10px; font-size:13px;'>
///<img src=images/check.png height='14' title='Completed' border=0><font color=#0080FF> <b>".$row['times_completed']."</b></font> |
///<img src=images/arrow_up.gif height='12' title='Seeders' border=0><font color=#00AA00><b>".$row['seeders']."</b></font> |
///<img src=images/arrow_down.gif height='12' title='Leechers' border=0><font color=#FF0000> <b>".$row['leechers']."</b></font>
///</div>";
///print("<td align=center>".$img1."</td>");
///}
///}
///print("</tr></table>");
///}
/// end_frame();
//===| End Recommended Torrents |===//
innodb=ON
#skip-federated
##skip-pbxt
##skip-pbxt_statistics
#skip-archive
#skip-name-resolve
#old_passwords
back_log = 200
max_connections = 200
key_buffer_size = 32M
myisam_sort_buffer_size = 64M
myisam_max_sort_file_size = 2048M
join_buffer_size = 128K
read_buffer_size = 128K
sort_buffer_size = 256K
table_definition_cache = 8192
table_open_cache = 4096
thread_cache_size = 128
wait_timeout = 1800
connect_timeout = 10
tmp_table_size = 128M
max_heap_table_size = 128M
max_allowed_packet = 2G
#max_seeks_for_key = 4294967295
#group_concat_max_len = 1024
max_length_for_sort_data = 1024
net_buffer_length = 8192
max_connect_errors = 100000
concurrent_insert = 2
read_rnd_buffer_size = 256K
bulk_insert_buffer_size = 8M
# query_cache boost for MariaDB >10.1.2+
# https://community.centminmod.com/posts/30811/
query_cache_limit = 128M
query_cache_size = 128M
query_cache_type = DEMAND
query_cache_min_res_unit = 2K
query_prealloc_size = 262144
query_alloc_block_size = 65536
transaction_alloc_block_size = 8192
transaction_prealloc_size = 4096
default-storage-engine = InnoDB
log_warnings=1
slow_query_log=1
long_query_time=0
log_queries_not_using_indexes =0
slow_query_log_file=/var/lib/mysql/slowq.log
log-error=/var/log/mysqld.log
# innodb settings
innodb_purge_threads = 4
innodb_file_per_table = 1
innodb_open_files = 4000
innodb_data_file_path= ibdata1:10M:autoextend
innodb_buffer_pool_size = 1920M
## https://mariadb.com/kb/en/mariadb/xtradbinnodb-server-system-variables/#innodb_buffer_pool_instances
innodb_buffer_pool_instances=1
innodb_log_files_in_group = 2
innodb_log_file_size = 128M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_thread_concurrency = 20
innodb_lock_wait_timeout=50
innodb_flush_method = O_DIRECT
# 200 * # DISKS
innodb_io_capacity = 2300
innodb_io_capacity_max = 3833
innodb_read_io_threads = 4
innodb_write_io_threads = 4
innodb_flush_neighbors = 1
# mariadb settings
[mariadb]
#thread-handling = pool-of-threads
#thread-pool-size= 20
#mysql --port=3307 --protocol=tcp
#extra-port=3307
#extra-max-connections=1
coco:i add it but is still need to reboot enable it ? whyMaybe this line is missing:[mysqld]sql-mode="NO_ENGINE_SUBSTITUTION"
[client]
socket=/var/lib/mysql/mysql.sock
[mysql]
max_allowed_packet = 48M
[mysqld]
ignore_db_dirs=cmsetiofiotest
local-infile=0
ignore_db_dirs=lost+found
character-set-server=utf8
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
#bind-address=127.0.0.1
# optimized my.cnf for MariaDB 5.5.x
# by eva2000
# centminmod.com
tmpdir=/home/mysqltmp
innodb=ON
#skip-federated
##skip-pbxt
##skip-pbxt_statistics
#skip-archive
#skip-name-resolve
#old_passwords
back_log = 200
max_connections = 200
key_buffer_size = 32M
myisam_sort_buffer_size = 64M
myisam_max_sort_file_size = 2048M
join_buffer_size = 128K
read_buffer_size = 128K
sort_buffer_size = 256K
table_definition_cache = 8192
table_open_cache = 4096
thread_cache_size = 128
wait_timeout = 1800
connect_timeout = 10
tmp_table_size = 128M
max_heap_table_size = 128M
max_allowed_packet = 48M
#max_seeks_for_key = 4294967295
#group_concat_max_len = 1024
max_length_for_sort_data = 1024
net_buffer_length = 8192
max_connect_errors = 100000
concurrent_insert = 2
read_rnd_buffer_size = 256K
bulk_insert_buffer_size = 8M
# query_cache boost for MariaDB >10.1.2+
# https://community.centminmod.com/posts/30811/
query_cache_limit = 1024K
query_cache_size = 64M
query_cache_type = 1
query_cache_min_res_unit = 2K
query_prealloc_size = 262144
query_alloc_block_size = 65536
transaction_alloc_block_size = 8192
transaction_prealloc_size = 4096
default-storage-engine = InnoDB
log_warnings=1
slow_query_log=0
long_query_time=1
slow_query_log_file=/var/lib/mysql/slowq.log
log-error=/var/log/mysqld.log
# innodb settings
innodb_purge_threads = 4
innodb_file_per_table = 1
innodb_open_files = 4000
innodb_data_file_path= ibdata1:10M:autoextend
innodb_buffer_pool_size = 192M
## https://mariadb.com/kb/en/mariadb/xtradbinnodb-server-system-variables/#innodb_buffer_pool_instances
innodb_buffer_pool_instances=1
innodb_log_files_in_group = 2
innodb_log_file_size = 128M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_thread_concurrency = 20
innodb_lock_wait_timeout=50
innodb_flush_method = O_DIRECT
# 200 * # DISKS
innodb_io_capacity = 2300
innodb_io_capacity_max = 3833
innodb_read_io_threads = 4
innodb_write_io_threads = 4
innodb_flush_neighbors = 1
# mariadb settings
[mariadb]
#thread-handling = pool-of-threads
#thread-pool-size= 20
#mysql --port=3307 --protocol=tcp
#extra-port=3307
#extra-max-connections=1
userstat = 0
key_cache_segments = 1
aria_group_commit = none
aria_group_commit_interval = 0
aria_log_file_size = 384M
aria_log_purge_type = immediate
aria_pagecache_buffer_size = 384M
aria_sort_buffer_size = 96M
[mariadb-5.5]
innodb_file_per_table = 1
#ignore_db_dirs=
query_cache_strip_comments=0
innodb_read_ahead = linear
innodb_adaptive_flushing_method = estimate
innodb_flush_neighbor_pages = 1
innodb_stats_update_need_lock = 0
innodb_log_block_size = 512
log_slow_filter =admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
[mysqld_safe]
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
#nice = -5
open-files-limit = 8192
[mysqldump]
quick
max_allowed_packet = 48M
[myisamchk]
tmpdir=/home/mysqltmp
key_buffer = 32M
sort_buffer = 16M
read_buffer = 16M
write_buffer = 16M
[mysqlhotcopy]
interactive-timeout
[mariadb-10.0]
innodb_file_per_table = 1
# 2 variables needed to switch from XtraDB to InnoDB plugins
#plugin-load=ha_innodb
#ignore_builtin_innodb
## MariaDB 10 only save and restore buffer pool pages
## warm up InnoDB buffer pool on server restarts
#innodb_buffer_pool_dump_at_shutdown=1
#innodb_buffer_pool_load_at_startup=1
innodb_buffer_pool_populate=0
## Disabled settings
performance_schema=OFF
innodb_stats_on_metadata=OFF
innodb_sort_buffer_size=2M
innodb_online_alter_log_max_size=128M
query_cache_strip_comments=0
log_slow_filter =admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
[mariadb-10.3]
#innodb_file_format = Barracuda
innodb_default_row_format = dynamic
innodb_file_per_table = 1
## wsrep specific
# wsrep_on=OFF
# wsrep_provider
# wsrep_cluster_address
# binlog_format=ROW
# default_storage_engine=InnoDB
# innodb_autoinc_lock_mode=2
# innodb_doublewrite=1
# query_cache_size=0
# 2 variables needed to switch from XtraDB to InnoDB plugins
#plugin-load=ha_innodb
#ignore_builtin_innodb
## MariaDB 10 only save and restore buffer pool pages
## warm up InnoDB buffer pool on server restarts
innodb_buffer_pool_dump_at_shutdown=1
innodb_buffer_pool_load_at_startup=1
## Disabled settings
performance_schema=OFF
innodb_stats_on_metadata=OFF
innodb_sort_buffer_size=2M
innodb_online_alter_log_max_size=128M
query_cache_strip_comments=0
log_slow_filter =admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
# Defragmenting unused space on InnoDB tablespace
innodb_defragment=1
innodb_defragment_n_pages=7
innodb_defragment_stats_accuracy=0
innodb_defragment_fill_factor_n_recs=20
innodb_defragment_fill_factor=0.9
innodb_defragment_frequency=40
# page compression
# 10.1+ https://mariadb.com/kb/en/mariadb/compression/
#innodb_compression_algorithm=zlib
#innodb_use_fallocate=0
#innodb_use_mtflush=0
#innodb_mtflush_threads=4