1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Update Seeds & Peer Help in Torrent Website

Discussion in 'Programming' started by SidhuZ, Oct 19, 2013.

  1. #1
    This is the code i'm using for updating stats for my website. http://piratex.us/What this script is doing is just updating stats of http Trackers. But i want a script that can update udp trackers as well. If Any one can help that will be great..

    if ($scrape =='1'){
                print("<td valign='top' align='right'><br />");
                $seeders1 = $leechers1 = $downloaded1 = null;
    
                $tres = SQL_Query_exec("SELECT url FROM announce WHERE torrent=$id");
                while ($trow = mysql_fetch_assoc($tres)) {
                    $ann = $trow["url"];
                    $tracker = explode("/", $ann);
                    $path = array_pop($tracker);
                    $oldpath = $path;
                    $path = preg_replace("/^announce/", "scrape", $path);
                    $tracker = implode("/", $tracker)."/".$path;
    
                    if ($oldpath == $path) {
                        continue; // Scrape not supported, ignored
                    }
    
                    // TPB's tracker is dead. Use openbittorrent instead
                    if (preg_match("/thepiratebay.org/i", $tracker) || preg_match("/prq.to/", $tracker)) {
                        $tracker = "http://tracker.openbittorrent.com/scrape";
                    }
    
                    $stats = torrent_scrape_url($tracker, $row["info_hash"]);
                    if ($stats['seeds'] != -1) {
                        $seeders1 += $stats['seeds'];
                        $leechers1 += $stats['peers'];
                        $downloaded1 += $stats['downloaded'];
                        SQL_Query_exec("UPDATE `announce` SET `online` = 'yes', `seeders` = $stats[seeds], `leechers` = $stats[peers], `times_completed` = $stats[downloaded] WHERE `url` = ".sqlesc($ann)." AND `torrent` = $id");
                    } else {
                        SQL_Query_exec("UPDATE `announce` SET `online` = 'no' WHERE `url` = ".sqlesc($ann)." AND `torrent` = $id");
    
                    }
                }
    
                if ($seeders1 !== null){ //only update stats if data is received
                    print ("<b>".T_("LIVE_STATS").": </b><br />");
                    print ("Seeders: ".number_format($seeders1)."<br />");
                    print ("Leechers: ".number_format($leechers1)."<br />");
                    print (T_("COMPLETED").": ".number_format($downloaded1)."<br />");
    
                    SQL_Query_exec("UPDATE torrents SET leechers='".$leechers1."', seeders='".$seeders1."', times_completed='".$downloaded1."',last_action= '".get_date_time()."',visible='yes' WHERE id='".$row['id']."'");
                }else{
                    print ("<b>".T_("LIVE_STATS").": </b><br />");
                    print ("<font color='#ff0000'>Tracker Timeout<br />Please retry later</font><br />");
                }
    
                print ("<form action='torrents-details.php?id=$id&amp;scrape=1' method='post'><input type=\"submit\" name=\"submit\" value=\"Update Stats\" /></form></td>");
            }else{
                print ("<td valign='middle' align='right'><br /><form action='torrents-details.php?id=$id&amp;scrape=1' method='post'><input type=\"submit\" name=\"submit\" value=\"Update Stats\" /></form></td>");
            }
        }
    PHP:
     
    SidhuZ, Oct 19, 2013 IP