• Страница 1 из 1
  • 1
Форум вебмастеров-Моды и хаки для трекера » Моды и Хаки » Готовые моды и хаки » Отлов читеров по скорости (Отлов читеров по скорости)
Отлов читеров по скорости
Slash3977Дата: Суббота, 10.07.2010, 11:17 | Сообщение # 1
Админ!и что?
Группа: Администраторы
Сообщений: 74
Репутация: 3
Статус: Offline
Суть: фиксирует пиров которые отдают со скоростью выше 2Мб/с,
также показывает за текущую сессию.
Фриков которые раздают со скоростью 20 МБ/с - 2 ТБ/с (да, да - есть и такие) баним смело smile

В базу добавляем таблицу reports

Quote
CREATE TABLE IF NOT EXISTS `reports` (
`id` int(10) unsigned NOT NULL auto_increment,
`userid` int(10) unsigned NOT NULL,
`torrentid` int(10) unsigned NOT NULL,
`date` int(11) NOT NULL,
`speed` float NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=cp1251 AUTO_INCREMENT=105 ;

в announce.php
после:

Quote
$seedtime = $st_arr['seedtime'] + $self['announcetime'];

добавить:
Quote
/* instant cheat mod */
$instant_speed = $upthis / $self['announcetime'];
$timenow = time();
if ($instant_speed > 2097152) // 2МБ - изменяем по усмотрению
{
$resS = mysql_query("SELECT `speed` FROM `reports` WHERE `userid` = $userid AND `torrentid` = $torrentid");
if (mysql_num_rows($resS) > 0)
{
$arrS = mysql_fetch_assoc($resS);
$maxspeed = $arrS['speed'];
if ($instant_speed > $maxspeed)
mysql_query("UPDATE `reports` SET `date` = '$timenow', `speed` = '$instant_speed'
WHERE `userid` = $userid AND `torrentid` = $torrentid");
} else
mysql_query("INSERT INTO reports (userid, torrentid, date, speed) VALUES ('$userid','$torrentid','$timenow','$instant_speed')");
}
/* instant cheat mod end */

В корень трекера добавляем файлы
cheat.php

Quote
<?
require "include/bittorrent.php";
dbconn(false);

loggedinorreturn();

stdhead();
print("<h1><font color=red>Скорость отдачи за текущую сессию</font></h1>");
print("<script src='/js/klrajax.js'></script><b>Показать пользователей, которые ''раздают'' со скоростью более</b>  <select name='speed' id='mb' onchange=\"var mb=document.getElementById('mb');var data = new Array();data[mb.name]=mb.value;HTTP.post('cheat_get.php',data,getLeechers,null);\">");
for($i=1; $i<11; $i++)
{
print("<option>$i</option>");
}
print("</select>  <b>Mb/s</b>");
?>
<script type="text/javascript">
function getLeechers(reply)
{
var xmlDoc = reply;
var cheaters = xmlDoc.getElementsByTagName('cheater');
oldTbl = document.getElementById('cheatbl');
leechDiv = document.getElementById('leechtbl');
if (leechDiv.firstChild) leechDiv.removeChild(oldTbl);
var chTbl = document.createElement('table');
chTbl.id = 'cheatbl';
chTbl.cellPadding='10px';
var tBody = document.createElement('tbody');

if (cheaters.length != 0)
{
leechDiv.innerHTML ='';
var titles = ['Пользователь', 'Название торрента', 'Залил', 'Сидирует', 'Скорость'];
var tr = document.createElement('tr');

for (var i = 0; i < titles.length; i++) {
var td = document.createElement('th');
td.appendChild(document.createTextNode(titles[i]));
tr.appendChild(td);
}
tBody.appendChild(tr);
} else
leechDiv.innerHTML = '<h3> Не обнаружено... </hr>';

for (var i=0; i<cheaters.length; i++)
{
var tr = document.createElement('tr');
var td = document.createElement('td');
var link = document.createElement('a');
link.href = 'userdetails.php?id='+cheaters[i].getElementsByTagName('userid')[0].firstChild.data
link.appendChild(document.createTextNode(cheaters[i].getElementsByTagName('user')[0].firstChild.data));
td.appendChild(link);
tr.appendChild(td);
var td = document.createElement('td');
var link = document.createElement('a');
link.href = 'details.php?id='+cheaters[i].getElementsByTagName('torrentid')[0].firstChild.data
link.appendChild(document.createTextNode(cheaters[i].getElementsByTagName('torrent')[0].firstChild.data));
td.appendChild(link);
tr.appendChild(td);
var td = document.createElement('td');
td.appendChild(document.createTextNode(cheaters[i].getElementsByTagName('uploaded')[0].firstChild.data));
tr.appendChild(td);
var td = document.createElement('td');
td.appendChild(document.createTextNode(cheaters[i].getElementsByTagName('seedtime')[0].firstChild.data));
td.align='center';
tr.appendChild(td);
var td = document.createElement('td');
td.appendChild(document.createTextNode(cheaters[i].getElementsByTagName('speed')[0].firstChild.data));
tr.appendChild(td);
tBody.appendChild(tr);
}
chTbl.appendChild(tBody);
leechDiv.appendChild(chTbl);
}
</script>
<div id="leechtbl"></div>
<br><br>
<h1><font color=red>Зафиксированые скорости</font></h1>
<table cellpadding=10px>
<tr>
<th><small>Пользователь</small></th>
<th><small>Название торрента</small></th>
<th><small>Скорость</small></th>
<th><small>Дата</small></th>
</tr>
<?

$res = mysql_query("SELECT date, speed, userid, torrentid, (SELECT username FROM users WHERE id=userid) as cheater, (SELECT warned FROM users WHERE id=userid) as warned, (SELECT name FROM torrents WHERE id=torrentid) as torrent FROM `reports`");
while ($arr = mysql_fetch_assoc($res))
{
print("<tr>");
$user = $arr['cheater'];
$torrent = $arr['torrent'];
$speed = mksize($arr['speed']);
$time = date("d.m h:m",$arr['date']);

if ($arr["warned"] == "yes")
print("<td><a href='userdetails.php?id=".$arr['userid']."'><font color=red> ".$user."</font></a> <img src=\"pic/warned.gif\" alt=\"Пользователь уже предупреждён!\"/></td><td><small><a href='details.php?id=".$arr['torrentid']."'>".$torrent."</a></small></td><td><small>".$speed."/s</small></td><td><small>".$time."</small></td>");
else
print("<td><small><a href='userdetails.php?id=".$arr['userid']."'> ".$user."</a></small></td><td><small><a href='details.php?id=".$arr['torrentid']."'>".$torrent."</a></small></td><td><small>".$speed."/s</small></td><td><small>".$time."</small></td>");
print("</tr>");
}
?>
</table>
<?

stdfoot();
?>

cheat_get.php

Quote
<?
require "include/bittorrent.php";
dbconn(false);
if ($_SERVER['REQUEST_METHOD'] != 'POST') die("Direct access to this file not allowed.");

$speed = mysql_real_escape_string($_POST['speed']);
$query = "SELECT userid, torrent as torrentid, (SELECT username FROM users WHERE id=userid) as cheater, (SELECT name FROM torrents WHERE id=torrent) as torrent, uploaded as 'uploaded', seedtime as 'seedtime', ((uploaded/(1024*1024)) / seedtime) as 'speed' FROM `snatched` WHERE ((uploaded/(1024*1024)) / seedtime) > $speed AND (id > 4000) LIMIT 30";
$res = mysql_query($query);

header("Content-type: text/xml");
print("<?xml version=\"1.0\" encoding=\"CP1251\"?>");
print('<content>');
while ($arr = mysql_fetch_assoc($res))
{
print('<cheater>
<user>'.$arr['cheater'].'</user>
<userid>'.$arr['userid'].'</userid>
<torrentid>'.$arr['torrentid'].'</torrentid>
<torrent>'.$arr['torrent'].'</torrent>
<uploaded>'.mksize($arr['uploaded']).'</uploaded>
<seedtime>'.mkprettytime($arr['seedtime']).'</seedtime>
<speed>'.number_format($arr['speed'],2).' MB/s</speed>
</cheater>');
}
print('</content>');

В папку js.
klrajax.js

Quote
/**
* @author kolor
*/
var HTTP = {};
// This is a list of XMLHttpRequest-creation factory functions to try
HTTP._factory = null;
HTTP._factories = [
function() { return new XMLHttpRequest(); },
function() { return new ActiveXObject("Msxml2.XMLHTTP"); },
function() { return new ActiveXObject("Microsoft.XMLHTTP"); }
];

// Create and return a new XMLHttpRequest object.
HTTP.newRequest = function() {
if (HTTP._factory != null) return HTTP._factory();

for(var i = 0; i < HTTP._factories.length; i++)
{
try
{
var factory = HTTP._factories[i];
var request = factory();
if (request != null)
{
HTTP._factory = factory;
return request;
}
} catch(e)
{
continue;
}
}
// If we get here, none of the factory candidates succeeded,
// so throw an exception now and for all future calls.
HTTP._factory = function()
{
throw new Error("XMLHttpRequest not supported");
}
HTTP._factory(); // Throw an error
}

// Encode the property name/value pairs of an object as if they were from
HTTP.encodeFormData = function(data)
{
var pairs = [];
var regexp = /%20/g; // A regular expression to match an encoded space

for(var name in data)
{
var value = data[name].toString();
var pair = encodeURIComponent(name).replace(regexp,"+") + '=' +
encodeURIComponent(value).replace(regexp,"+");
pairs.push(pair);
}
// Concatenate all the name/value pairs, separating them with &
return pairs.join('&');
};

HTTP._getResponse = function(request)
{
switch(request.getResponseHeader("Content-Type"))
{
case "text/xml":
return request.responseXML;

case "text/json":
case "text/javascript":
case "application/javascript":
case "application/x-javascript":
return eval(request.responseText);

default:
return request.responseText;
}
};

// Send GET request using XMLHttpRequest
HTTP.getText = function(url, callback)
{
var request = HTTP.newRequest();
request.onreadystatechange = function()
{
if (request.readyState == 4 && request.status == 200)
callback(HTTP._getResponse(request));
}
request.open("GET", url);
request.send(null);
};

// Send POST request using XMLHttpRequest
HTTP.post = function(url, values, callback, errorHandler)
{
var request = HTTP.newRequest();
request.onreadystatechange = function()
{
if (request.readyState == 4)
if (request.status == 200)
callback(HTTP._getResponse(request));
else
if (errorHandler)
errorHandler(request.status, request.statusText);
else callback(null);
}
request.open("POST", url);
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
request.send(HTTP.encodeFormData(values));
};

 
Форум вебмастеров-Моды и хаки для трекера » Моды и Хаки » Готовые моды и хаки » Отлов читеров по скорости (Отлов читеров по скорости)
  • Страница 1 из 1
  • 1
Поиск: