View Single Post
  #3  
Old 29th September 2010, 17:54
DND DND is offline
VIP
 
Join Date: Dec 2008
Posts: 1,243
Default
that's it ?
i have a more complex one ..
with Ban Bittorent Clients by petrified ..
and some clients i get as unkown in the peers table

Code:
function getagent($httpagent, $peer_id="")
{

if ($peer_id!="")
    $peer_id=hex2bin($peer_id);

//if (preg_match("/^Azureus ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]\_B([0-9][0-9|*])(.+)$)/", $httpagent, $matches))
//return "Azureus/$matches[1]";
//elseif (preg_match("/^Azureus ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]\_[a-zA-Z]+)/", $httpagent, $matches))
//return "Azureus/$matches[1]";
//elseif (preg_match("/^Azureus ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]\_CVS)/", $httpagent, $matches))
//return "Azureus/$matches[1]";
if (preg_match("/^Java\/([0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
return "Azureus/<2.0.7.0";
//elseif (preg_match("/^Azureus ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
//return "Azureus/$matches[1]";
elseif (preg_match("/BitTorrent\/S-([0-9]+\.[0-9]+(\.[0-9]+)*)/", $httpagent, $matches))
return "Shadow's/$matches[1]";
elseif (preg_match("/BitTorrent\/U-([0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
return "UPnP/$matches[1]";
elseif (preg_match("/^BitTor(rent|nado)\\/T-(.+)$/", $httpagent, $matches))
return "BitTornado/$matches[2]";
elseif (preg_match("/^BitTornado\\/T-(.+)$/", $httpagent, $matches))
return "BitTornado/$matches[1]";
elseif (preg_match("/^BitTorrent\/ABC-([0-9]+\.[0-9]+(\.[0-9]+)*)/", $httpagent, $matches))
return "ABC/$matches[1]";
elseif (preg_match("/^ABC ([0-9]+\.[0-9]+(\.[0-9]+)*)\/ABC-([0-9]+\.[0-9]+(\.[0-9]+)*)/", $httpagent, $matches))
return "ABC/$matches[1]";
elseif (preg_match("/ABC\/ABC-([0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
return "ABC/$matches[1]";
elseif (preg_match("/ABC\/AO([0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
return "ABC/AO$matches[1]";
elseif (preg_match("/^Python-urllib\/.+?, BitTorrent\/([0-9]+\.[0-9]+(\.[0-9]+)*)/", $httpagent, $matches))
return "BitTorrent/$matches[1]";
elseif (ereg("^BitTorrent\/BitSpirit$", $httpagent))
return "BitSpirit";
elseif (ereg("^DansClient", $httpagent))
return "XanTorrent";
elseif (preg_match("/^BitTorrent\/brst(.+)/", $httpagent, $matches))
return "Burst/$matches[1]";
elseif (preg_match("/^RAZA (.+)$/", $httpagent, $matches))
return "Shareaza/$matches[1]";
elseif (preg_match("/Rufus\/([0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
return "Rufus/$matches[1]";
elseif (preg_match("/uTorrent\/([0-9]+)([0-9]+)([0-9]+)([0-9]+)/", $httpagent, $matches))
return "uTorrent/$matches[1].$matches[2].$matches[3]";
elseif (preg_match("/uTorrent\/([0-9]+)([0-9]+)([0-9]+)/", $httpagent, $matches))
return "uTorrent/$matches[1].$matches[2].$matches[3]";
elseif (preg_match("/uTorrent\/([0-9]+[0-9]+[0-9]+B)/", $httpagent, $matches))
return "uTorrent/$matches[1]";
elseif (preg_match("/Acquisition\/([0-9]+[0-9]+[0-9]+\.[0-9])/", $httpagent, $matches))
return "Acquisition/$matches[1]";
elseif (preg_match("/BitComet Turbo ([0-9]+\.[0-9]+\.[0-9]+.[0-9])/", $httpagent, $matches))
return "BitComet Turbo/$matches[1]";
elseif (preg_match("/btpd\/([0-9]+\.[0-9])/", $httpagent, $matches))
return "btpd/$matches[1]";
elseif ((strpos($httpagent, 'BitTorrent/4.1.2')!== false) && (substr($peer_id, 2, 2) == "BS"))
return "BitSpirit/v3";
if (preg_match("/rtorrent\/([0-9]+\.[0-9]+\.[0-9]+\/[0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
return "rtorrent/$matches[1]";
if (preg_match("/libtorrent\/([0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
return "libtorrent/$matches[1]";
if (preg_match("/Transmission\/([0-9]+\.[0-9]+)/", $httpagent, $matches))
return "Transmission/$matches[1]";
if (preg_match("/Shareaza\ ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
return "Shareaza $matches[1]";
elseif (preg_match("/^BitsOnWheels ([0-9]+\.[0-9]+\.[0-9])/", $httpagent, $matches))
return "BitsOnWheels/$matches[1]";
elseif (preg_match("/ktorrent\/([0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
return "KTorrent/$matches[1]";
elseif (preg_match("/ktorrent\/([0-9]+\.[0-9]+)/", $httpagent, $matches))
return "KTorrent/$matches[1]";
elseif (preg_match("/GetRight\/([0-9]+\.[0-9]+[a-z])/", $httpagent, $matches))
return "GetRight/$matches[1]";
elseif (preg_match("/^0P3R4H BT/", $httpagent, $matches))
return "0P3R4H_BT";
elseif (preg_match("/Fast Torrent ([0-9]+\.[0-9]+\.[0-9]+.[0-9])/", $httpagent, $matches))
return "FastTorrent/$matches[1]";
elseif (preg_match("/^BitTorrent\\/([0-9]+\\.[0-9]+(\\.[0-9]+)*)/", $httpagent, $matches))
{
if(substr($peer_id, 0, 6) == "exbc\08")
return "BitComet/0.56";
elseif(substr($peer_id, 0, 6) == "exbc\09")
return "BitComet/0.57";
elseif(substr($peer_id, 0, 6) == "exbc\0:")
return "BitComet/0.58";
elseif(substr($peer_id, 0, 7) == "exbc\0L")
return "BitLord/1.0";
elseif(substr(bin2hex($peer_id), 0, 14) == "6578626301014C")
return "BitLord/1.1";
elseif(substr(bin2hex($peer_id), 0, 14) == "6578626302004C")
return "BitLord/2.0";
elseif(substr($peer_id, 0, 8) == "-GR5907-")
return "GetRightPro/6.0beta7";
else
return "BitTorrent/$matches[1]";
}
elseif(substr($peer_id, 0, 5) == "-BC00")
return "BitComet/0.".substr($peer_id, 5, 2);
elseif(substr($peer_id, 0, 5) == "-BC01")
return "BitComet/1.".substr($peer_id, 5, 2);
elseif (preg_match("/^Python-urllib\\/([0-9]+\\.[0-9]+(\\.[0-9]+)*)/", $httpagent, $matches))
return "G3 Torrent";
elseif (preg_match("/MLdonkey( |\/)([0-9]+\\.[0-9]+).*/", $httpagent, $matches))
return "MLdonkey$matches[1]";
elseif (preg_match("/MLDonkey\/([0-9]+\.[0-9]+\.[0-9]+)/", $httpagent, $matches))
return "MLDonkey/$matches[1]";
elseif (preg_match("/ed2k_plugin v([0-9]+\\.[0-9]+).*/", $httpagent, $matches))
return "eDonkey/$matches[1]";
elseif(substr($peer_id, 0, 8) == "-CD0201-")
return "CTorrent/2.1";
elseif(substr($peer_id, 0, 4) == "-qB0")
return "QBittorrent/0.".substr($peer_id, 4, 1);
elseif(substr($peer_id, 0, 3) == "-KT")
return "KTorrent/".substr($peer_id, 3, 1).".".substr($peer_id, 4, 1);
elseif(substr($peer_id, 0, 8) == "AZ2500BT")
return "Azureus BitTyrant";
elseif(substr($peer_id, 0, 3) == "-AG")
return "Ares/".substr($peer_id, 3, 1).".".substr($peer_id, 4, 1).".".substr($peer_id, 5, 1).".".substr($peer_id, 6, 1);
elseif(substr($peer_id, 0, 3) == "-lt")
return "libTorrent/".hexdec(substr($peer_id, 3, 1)).".".hexdec(substr($peer_id, 4, 1)).".".hexdec(substr($peer_id, 5, 1));
elseif(substr($peer_id, 0, 3) == "-LT")
return "Free_Download_Manager";
elseif(substr($peer_id, 0, 8) == "-CD0202-")
return "CTorrent";
elseif(substr($peer_id, 0, 3) == "-LP")
return "Lphant/".substr($peer_id, 4, 1).".".substr($peer_id, 5, 2);
elseif(substr($peer_id, 0, 3) == "-BF")
{
    if(substr($peer_id, 3, 4) == "6110")
        $ver="0.10";
    elseif(substr($peer_id, 3, 4) == "6C05")
        $ver="0.20";
    elseif(substr($peer_id, 3, 4) == "6C0F")
        $ver="0.21";
    elseif(substr($peer_id, 3, 4) == "7114")
        $ver="0.22";
    elseif(substr($peer_id, 3, 4) == "7127")
        $ver="0.30";
    elseif(substr($peer_id, 3, 4) == "7128")
        $ver="0.31";
    elseif(substr($peer_id, 3, 4) == "7224")
        $ver="0.32";
    else $ver="??";
    return "BitFlu/".$ver;
}
elseif(substr($peer_id, 0 , 2)=="OP")
return "Opera";
elseif(substr($peer_id, 1, 2)=="DE")
return "Deluge/".substr($peer_id, 3, 1).".".substr($peer_id, 4, 1).".".substr($peer_id, 5, 1).".".substr($peer_id, 6, 1);
elseif(substr($peer_id, 0 , 1)=="M" && substr($peer_id, 2 , 1)=="-" && substr($peer_id, 4 , 1)=="-")
return "BitTorrent/".substr($peer_id, 1, 1).".".substr($peer_id, 3, 1).".".substr($peer_id, 5, 1);
elseif(substr($httpagent,0,8)=="LimeWire" && (substr($peer_id,0,4)=="LIME") || substr($peer_id,1,2)=="LW")
return $httpagent;
elseif(substr($httpagent,0,4)=="Plus")
return "BitTorrent Plus! II/".substr($peer_id, 4, 1).".".substr($peer_id, 5, 1)." Beta ".substr($peer_id, 6, 1);
elseif(substr($peer_id, 1, 2)=="HL")
return "Halite/".intval(substr($peer_id,3,2)).".".substr($peer_id,5,1);
elseif(substr($peer_id, 1, 2)=="CD")
return "Enhanced CTorrent/".intval(substr($peer_id,3,2)).".".intval(substr($peer_id,5,2));
elseif(substr($peer_id, 1, 2)=="XL" || substr($peer_id, 1, 2)=="SD")
return "Xunlei/".intval(substr($peer_id,3,2)).".".intval(substr($peer_id,5,2));
elseif(substr($peer_id, 1, 2)=="TT")
return "TuoTu/".substr($peer_id,3,1).".".substr($peer_id,4,1).".".substr($peer_id,5,1);
elseif(substr($peer_id, 1, 2)=="AZ" && substr($peer_id, 3, 2)<31)
return "Azureus/".substr($peer_id,3,1).".".substr($peer_id,4,1).".".substr($peer_id,5,1).".".substr($peer_id,6,1);
elseif(substr($peer_id, 1, 2)=="AZ" && substr($peer_id, 3, 2)>=31)
return "Vuze/".substr($peer_id,3,1).".".substr($peer_id,4,1).".".substr($peer_id,5,1).".".substr($peer_id,6,1);
elseif(substr($peer_id, 1, 2)=="UM")
return "uTorrent_Mac/".substr($peer_id,3,1).".".substr($peer_id,4,1).".".substr($peer_id,5,1).".".substr($peer_id,6,1);
elseif(substr($peer_id, 1, 2)=="BE")
return "BitTorrent_SDK/".substr($peer_id,3,1).".".substr($peer_id,4,1);
elseif(substr($peer_id, 1, 2)=="LH")
return "LH-ABC/".substr($peer_id,3,1).".".substr($peer_id,4,1).".".substr($peer_id,5,1).".".substr($peer_id,6,1);
elseif(substr($peer_id, 1, 2)=="FC")
return "FileCroc/".substr($peer_id,3,1).".".substr($peer_id,4,1).".".substr($peer_id,5,1).".".substr($peer_id,6,1);
elseif(substr($peer_id, 1, 2)=="ML")
return "MLdonkey/".substr($peer_id,3,5);
elseif(substr($peer_id, 1, 5)=="aria2")
return "aria2";
elseif(substr($peer_id, 1, 2)=="OS")
return "OneSwarm/".substr($peer_id,3,1).".".substr($peer_id,4,1);
elseif(substr($peer_id, 1, 4)=="UT16" && $httpagent=="uTorrent 1.5")
return "uTorrent/1.6.".substr($peer_id,5,1);
elseif(substr($peer_id, 1, 6)=="AR1001" && $httpagent=="(libtorrent)")
return "Arctic/1.2.3";
elseif(substr($peer_id, 1, 2)=="qB")
return "qBittorent/".substr($peer_id,3,1).".".substr($peer_id,4,1).".".substr($peer_id,5,1);
elseif(substr($peer_id, 0, 1)=="O")
return "Osprey Permaseed/".substr($peer_id,1,1).".".substr($peer_id,2,1);
else
return "Unknown Client (".substr($peer_id, 0, 8).")";
}
Reply With Quote