예제 #1
0
파일: funcsv2.php 프로젝트: j3k0/Wobi
function trashCollector($hash, $timeout)
{
    require "config.php";
    //need to grab prefix value...
    if (isset($GLOBALS["trackerid"])) {
        unset($GLOBALS["trackerid"]);
    }
    if (!Lock($hash)) {
        return;
    }
    $results = mysql_query("SELECT lastcycle FROM " . $prefix . "summary WHERE info_hash='{$hash}'");
    $lastcheck = mysql_fetch_row($results);
    // Check once every re-announce cycle
    if ($lastcheck[0] + $timeout < time()) {
        $peers = loadLostPeers($hash, $timeout);
        for ($i = 0; $i < $peers["size"]; $i++) {
            killPeer($peers[$i]["peer_id"], $hash, $peers[$i]["bytes"]);
        }
        summaryAdd("lastcycle", "UNIX_TIMESTAMP()", true);
    }
    Unlock($hash);
}
function myTrashCollector($hash, $timeout, $now, $writeout)
{
    $peers = loadLostPeers($hash, $timeout);
    for ($i = 0; $i < $peers["size"]; $i++) {
        killPeer($peers[$i]["peer_id"], $hash, $peers[$i]["bytes"], $peers[$i]);
    }
    if ($i != 0) {
        echo "<td>Removed {$i}</td>";
    } else {
        echo "<td>Removed 0</td>";
    }
    quickQuery("UPDATE BTPHP_summary SET lastcycle='{$now}' WHERE info_hash='{$hash}'");
}
예제 #3
0
         if ($resu && $resu->num_rows == 1) {
             $curuid = $resu->fetch_array(MYSQLI_BOTH);
             quickQuery("UPDATE history SET active = 'yes', agent = '" . getagent($agent, $peer_id) . "' WHERE uid = " . (int) $curuid["id"] . " AND infohash = '" . $info_hash . "'");
             // record is not present, create it (only if not seeder: original seeder don't exist in history table, other already exists)
             if ($db->affected_rows == 0 && $left > 0) {
                 quickQuery("INSERT INTO history (uid, infohash, active, agent) VALUES (" . (int) $curuid["id"] . ", '" . $info_hash . "', 'yes', '" . getagent($agent, $peer_id) . "')");
             }
         }
         $resu->free();
     }
     break;
     // client sent stop
 // client sent stop
 case "stopped":
     verifyTorrent($info_hash) or show_error("Torrent is not authorized for use on this tracker.");
     killPeer($peer_id, $info_hash, $left);
     // I don't know why, but the real tracker returns peers on event=stopped
     // but I'll just send an empty list. On the other hand,
     // TheSHADOW asked for this.
     if (isset($_GET["tracker"])) {
         $peers = getRandomPeers($info_hash);
     } else {
         $peers = array("size" => 0);
     }
     sendPeerList($peers);
     // update user uploaded/downloaded
     if (!$LIVESTATS) {
         @$db->query("UPDATE users SET uploaded = IFNULL(uploaded, 0) + " . $uploaded . ", downloaded = IFNULL(downloaded, 0) + " . $downloaded . " WHERE " . ($PRIVATE_ANNOUNCE ? "pid = '" . $pid . "'" : "cip = '" . $ip . "'") . " AND id > 1 LIMIT 1");
     }
     // begin history - if LIVESTAT, only the active/agent part
     if ($LOG_HISTORY) {
예제 #4
0
파일: announce.php 프로젝트: zzszms/sikemi
}
$db->query("UPDATE {$tablepre}xbtit_history set uploaded=IFNULL(uploaded,0)+{$new_upload},realup=IFNULL(realup,0)+{$new_upload_true},downloaded=IFNULL(downloaded,0)+{$new_download},realdown=IFNULL(realdown,0)+{$new_download_true},date=UNIX_TIMESTAMP(),tid={$tid} WHERE uid={$uid} AND infohash='{$info_hash}'");
mysql_free_result($resu);
// end history
// 记录到peers
$db->query("UPDATE {$tablepre}xbtit_history set realup={$uploaded},realdown={$downloaded} WHERE uid={$uid} AND infohash='{$info_hash}'");
//更新活动时间
$db->query("UPDATE {$tablepre}xbtit_files set lastactive=UNIX_TIMESTAMP() WHERE info_hash='{$info_hash}'");
$db->query("UPDATE {$tablepre}xbtit_history set date=UNIX_TIMESTAMP() WHERE uid={$uid} and infohash='{$info_hash}'");
switch ($event) {
    case "started":
        $start = start($info_hash, $ip, $port, $uid, $tid);
        sendRandomPeers($info_hash);
        break;
    case "stopped":
        killPeer($uid, $info_hash);
        sendRandomPeers($info_hash);
        break;
    case "completed":
        $peer_exists = getPeerInfo($uid, $info_hash);
        if (!is_array($peer_exists)) {
            start($info_hash, $ip, $port, $uid, $tid);
        } else {
            $db->query("UPDATE {$tablepre}xbtit_peers SET status=\"seeder\", lastupdate=UNIX_TIMESTAMP() WHERE uid={$uid} AND infohash=\"{$info_hash}\"");
            if (mysql_affected_rows() == 1) {
                add_finished($info_hash);
            }
        }
        sendRandomPeers($info_hash);
        break;
    case "":
예제 #5
0
function trashCollector($hash, $timeout)
{
    global $db;
    if (isset($GLOBALS["trackerid"])) {
        unset($GLOBALS["trackerid"]);
    }
    if (!Lock($hash)) {
        return;
    }
    $results = $db->query("SELECT lastcycle FROM summary WHERE info_hash = '" . $hash . "'");
    $lastcheck = $results->fetch_row();
    // Check once every re-announce cycle
    if ($lastcheck[0] + $timeout < vars::$timestamp) {
        $peers = loadLostPeers($hash, $timeout);
        for ($i = 0; $i < $peers["size"]; $i++) {
            killPeer($peers[$i]["peer_id"], $hash, $peers[$i]["bytes"]);
        }
        summaryAdd("lastcycle", "UNIX_TIMESTAMP()", true);
    }
    Unlock($hash);
}
function checkForStalePeers($hash, $timeout, $now, $cellBG, $outputHTML = false)
{
    /*
     * Get a list of stale peers...
     */
    $peers = loadLostPeers($hash, $timeout);
    /*
     * ... and remove them
     */
    for ($i = 0; $i < $peers["size"]; $i++) {
        killPeer($peers[$i]["peer_id"], $hash, $peers[$i]["bytes"], $peers[$i]);
    }
    /*
     * Show status, if needed...
     */
    if ($outputHTML) {
        if ($i != 0) {
            echo "\t\t<TD CLASS=\"consistency\">Removed {$i}</TD>\r\n";
        } else {
            echo "\t\t<TD {$cellBG}>Removed 0</TD>\r\n";
        }
    }
    quickQuery("UPDATE summary SET lastcycle='{$now}' WHERE info_hash='{$hash}'");
}
예제 #7
0
function myTrashCollector($hash, $timeout, $now, $writeout)
{
    $peers = loadLostPeers($hash, $timeout);
    for ($i = 0; $i < $peers["size"]; $i++) {
        killPeer($peers[$i]["peer_id"], $hash, $peers[$i]["bytes"], $peers[$i]);
    }
    quickQuery("UPDATE " . $prefix . "summary SET lastcycle='{$now}' WHERE info_hash='{$hash}'");
}
예제 #8
0
파일: sanity.php 프로젝트: j3k0/Wobi
function myTrashCollector($hash, $timeout, $now, $writeout)
{
    //	error_log("Trash collector working on $hash");
    require "config.php";
    $peers = loadLostPeers($hash, $timeout);
    for ($i = 0; $i < $peers["size"]; $i++) {
        killPeer($peers[$i]["peer_id"], $hash, $peers[$i]["bytes"], $peers[$i]);
    }
    if ($i != 0) {
        echo "<td class=\"center\">Removed {$i}</td>";
    } else {
        echo "<td class=\"center\">Removed 0</td>";
    }
    quickQuery("UPDATE " . $prefix . "summary SET lastcycle='{$now}' WHERE info_hash='{$hash}'");
}