Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Torrent Strike (http://www.bvlist.com/forumdisplay.php?f=21)
-   -   Auto delete torrents (http://www.bvlist.com/showthread.php?t=245)

Swompen 24th April 2008 15:21

Auto delete torrents
 
I need help with these things:
Remove auto delete on torrents
Fix Freeleech, dosent work.

What can it be? i'm using Fusion!

Neptune 24th April 2008 20:18

Re: Auto delete torrents
 
Delete torrents after x days?
Freeleech doesn't work?
Are you sure?

Swompen 24th April 2008 21:54

Re: Auto delete torrents
 
Yes, how do i remove TTL or what it says, and Yes freeleech dosent work for me, it still counts !
AND how do i change so VIP can upload?


and

Code:

$ttl = (floor($torrent_ttl/3600)) - floor((gmtime() - sql_timestamp_to_unix_timestamp($row["added"])) / 3600);
                if ($ttl == 1) $ttl .= "
hour"; else $ttl .= "
hours";
        print("
\n");
in userdetails.php
remove

Code:


and
remove

Code:

$ttl = (28*24) - floor((gmtime() - sql_timestamp_to_unix_timestamp($arr["added"])) / 3600);
        if ($ttl == 1) $ttl .= "
hour"; else $ttl .= "
hours";

and finally
remove

Code:



Quote:
Neptune 24th April 2008 23:31

Re: Auto delete torrents
 
Quote:

Originally Posted by Swompen
Yes, how do i remove TTL or what it says

in cleanup.php
remove

Code:

// delete old torrents
        $dt = sqlesc(get_date_time(gmtime() - $torrent_ttl));
        $res = mysql_query("SELECT id, name FROM torrents WHERE added < $dt AND seeders=0 AND leechers=0 ");
        while ($arr = mysql_fetch_assoc($res))
        {
                @unlink("$torrent_dir/$arr[id].torrent");
                mysql_query("DELETE FROM torrents WHERE id=$arr[id]");
                mysql_query("DELETE FROM peers WHERE torrent=$arr[id]");
                mysql_query("DELETE FROM comments WHERE torrent=$arr[id]");
                mysql_query("DELETE FROM files WHERE torrent=$arr[id]");
                write_log("Torrent $arr[id] ($arr[name]) was deleted by system (older than $days days)");
        }

in bittorrent.php
torrenttable

remove

Code:

TTL $ttl TTL $ttl

Originally Posted by Swompen
and Yes freeleech dosent work for me, it still counts !

It works, I think.
You can test the freeleech here -> tsf
Ask to Fynnon if you can be Uploader, and then you can test it.


Quote:

Originally Posted by Swompen
AND how do i change so VIP can upload?

What? Upload torrents?
Swompen 25th April 2008 06:34

Re: Auto delete torrents
 
Yes so vips are able to upload, and the freeleech dont work on my site.. http://www.teamnepal.se reg and give me a shout ! and ty for the help! (sry for the swedish text on the site)

And how to remove so when i type a " in a text it dosent go / or \

Neptune 25th April 2008 14:25

Re: Auto delete torrents
 
in upload.php

change

Code:

if (get_user_class() < UC_UPLOADER)
{
  stdmsg("Blabla", "Blablabla");
  stdfoot();
  exit;
}

to

Code:

if (get_user_class() < UC_VIP)
{
  stdmsg("Blabla", "Blablabla");
  stdfoot();
  exit;
}

And post your announce.php


end_frame();
?>



stdfoot();

?>
and i want vips and uploaders to be able to upload
Swompen 25th April 2008 16:14

Re: Auto delete torrents
 
Announce.php
Code:


ob_start("ob_gzhandler");

require_once("include/bittorrent.php");
require_once("include/benc.php");



function err($msg)
{
        benc_resp(array("failure reason" => array(type => "string", value => $msg)));
        exit();
}

function benc_resp($d)
{
        benc_resp_raw(benc(array(type => "dictionary", value => $d)));
}

function benc_resp_raw($x)
{
        header("Content-Type: text/plain");
        header("Pragma: no-cache");
        print($x);
}

$req = "info_hash:peer_id:!ip:port:uploaded:downloaded:left:!event:!passkey";
foreach (explode(":", $req) as $x)
{
        if ($x[0] == "!")
        {
                $x = substr($x, 1);
                $opt = 1;
        }
        else
                $opt = 0;
        if (!isset($_GET[$x]))
        {
                if (!$opt)
                        err("missing key");
                continue;
        }
        $GLOBALS[$x] = unesc($_GET[$x]);
}

if (ENA_PASSKEY && (
                strlen($passkey) != 32 &&
                @mysql_num_rows(@mysql_query("SELECT id FROM users WHERE passkey=" . sqlesc($passkey))) != 1))
        err("Invalid passkey! Re-download the .torrent from $BASEURL ($passkey)");
$passkey=sqlesc($passkey);       

foreach (array("info_hash","peer_id") as $x)
{
        if (strlen($GLOBALS[$x]) != 20)
                err("invalid $x (" . strlen($GLOBALS[$x]) . " - " . urlencode($GLOBALS[$x]) . ")");
}

//if (empty($ip) || !preg_match('/^(\d{1,3}\.){3}\d{1,3}$/s', $ip))
        $ip = getip();

$port = 0 + $port;
$downloaded = 0 + $downloaded;
$uploaded = 0 + $uploaded;
$left = 0 + $left;

$rsize = 50;
foreach(array("num want", "numwant", "num_want") as $k)
{
        if (isset($_GET[$k]))
        {
                $rsize = 0 + $_GET[$k];
                break;
        }
}

$agent = $_SERVER["HTTP_USER_AGENT"];

// Deny access made with a browser...
//if (ereg("^Mozilla\\/", $agent) || ereg("^Opera\\/", $agent) || ereg("^Links ", $agent) || ereg("^Lynx\\/", $agent))
//        err("torrent not registered with this tracker");

if (!$port || $port > 0xffff)
        err("invalid port");

if (!isset($event))
        $event = "";

$seeder = ($left == 0) ? "yes" : "no";




$res = mysql_query("SELECT id, banned, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts FROM torrents WHERE " . hash_where("info_hash", $info_hash));

$torrent = mysql_fetch_assoc($res);
if (!$torrent)
        err("torrent not registered with this tracker");

$torrentid = $torrent["id"];

$fields = "seeder, peer_id, ip, port, uploaded, downloaded, userid";

$numpeers = $torrent["numpeers"];
$limit = "";
if ($numpeers > $rsize)
        $limit = "ORDER BY RAND() LIMIT $rsize";
$res = mysql_query("SELECT $fields FROM peers WHERE torrent = $torrentid AND connectable = 'yes' $limit");

$resp = 'd' . benc_str('interval') . 'i' . $announce_interval . 'e' . benc_str('peers') . (($compact = ($_GET['compact'] == 1))?'':'l');
unset($self);
while ($row = mysql_fetch_assoc($res))
{
        $row["peer_id"] = hash_pad($row["peer_id"]);

        if ($row["peer_id"] === $peer_id)
        {
                $userid = $row["userid"];
                $self = $row;
                continue;
        }
        if($compact)
        {
                $peer_ip = explode('.', $row["ip"]);
                $plist .= pack("C*", $peer_ip[0], $peer_ip[1], $peer_ip[2], $peer_ip[3]). pack("n*", (int)$row["port"]);
        } else {
                $resp .= "d" .
                benc_str("ip") . benc_str($row["ip"]) .
                benc_str("peer id") . benc_str($row["peer_id"]) .
                benc_str("port") . "i" . $row["port"] . "e" .
                "e";
        }
}

$resp .= ($compact ? benc_str($plist):''). "ee";

$selfwhere = "torrent = $torrentid AND ". (ENA_PASSKEY ?"passkey=$passkey AND ":'') . hash_where("peer_id", $peer_id);

if (!isset($self))
{
        $res = mysql_query("SELECT $fields FROM peers WHERE $selfwhere");
        $row = mysql_fetch_assoc($res);
        if ($row)
        {
                $userid = $row["userid"];
                $self = $row;
        }
}

//// Up/down stats ////////////////////////////////////////////////////////////

if (!isset($self))
{
        if(ENA_PASSKEY && ENA_PASSKEYLIMITCONNECTIONS)
        {
                $valid = @mysql_num_rows(@mysql_query("SELECT id FROM peers WHERE torrent=$torrentid AND passkey=$passkey"));
                if ($valid[0] >= 1 && $seeder == 'no')
                        err("Connection limit exceeded! You may only leech from one location at a time.");
                if ($valid[0] >= 3 && $seeder == 'yes')
                        err("Connection limit exceeded!");
        }
        $rz = mysql_query("SELECT id, uploaded, downloaded, class FROM users WHERE ip='$ip' AND enabled = 'yes' ". (ENA_PASSKEY ? "AND passkey=$passkey ":''). "ORDER BY last_access DESC LIMIT 1") or err("Tracker error 2");
        if ($MEMBERSONLY && mysql_num_rows($rz) == 0)
                err("Unrecognized host ($ip). Please go to $BASEURL to sign-up or login.");
        $az = mysql_fetch_assoc($rz);
        $userid = $az["id"];

//        if ($left > 0 && $az["class"] < UC_USER)
        if ($az["class"] < UC_USER)
        {
                $gigs = $az["uploaded"] / (1024*1024*1024);
                $elapsed = floor((gmtime() - $torrent["ts"]) / 3600);
                $ratio = (($az["downloaded"] > 0) ? ($az["uploaded"] / $az["downloaded"]) : 1);
                if ($ratio < 0.5 || $gigs < 5) $wait = 48;
                elseif ($ratio < 0.65 || $gigs < 6.5) $wait = 24;
                elseif ($ratio < 0.8 || $gigs < 8) $wait = 12;
                elseif ($ratio < 0.95 || $gigs < 9.5) $wait = 6;
                else $wait = 0;
                if (($elapsed < $wait)&&($seeder == 'no'))
                                err("Not authorized (" . ($wait - $elapsed) . "h) - READ THE FAQ!");
        }
}
else
{
        $upthis = max(0, $uploaded - $self["uploaded"]);
        $downthis = max(0, $downloaded - $self["downloaded"]);

        if ($upthis > 0 || $downthis > 0)
                mysql_query("UPDATE users SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis WHERE id=$userid") or err("Tracker error 3");
}

///////////////////////////////////////////////////////////////////////////////

function portblacklisted($port)
{
        // direct connect
        if ($port >= 411 && $port <= 413) return true;

        // bittorrent
        if ($port >= 6881 && $port <= 6889) return true;

        // kazaa
        if ($port == 1214) return true;

        // gnutella
        if ($port >= 6346 && $port <= 6347) return true;

        // emule
        if ($port == 4662) return true;

        // winmx
        if ($port == 6699) return true;

        return false;
}

$updateset = array();

if ($event == "stopped")
{
        if (isset($self))
        {
                mysql_query("DELETE FROM peers WHERE $selfwhere");
                if (mysql_affected_rows())
                {
                        if ($self["seeder"] == "yes")
                                $updateset[] = "seeders = seeders - 1";
                        else
                                $updateset[] = "leechers = leechers - 1";
                }
        }
}
else
{
        if ($event == "completed")
                $updateset[] = "times_completed = times_completed + 1";

        if (isset($self))
        {
                mysql_query("UPDATE peers SET uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = NOW(), seeder = '$seeder'"
                        . ($seeder == "yes" && $self["seeder"] != $seeder ? ", finishedat = " . time() : "") . " WHERE $selfwhere");
                if (mysql_affected_rows() && $self["seeder"] != $seeder)
                {
                        if ($seeder == "yes")
                        {
                                $updateset[] = "seeders = seeders + 1";
                                $updateset[] = "leechers = leechers - 1";
                        }
                        else
                        {
                                $updateset[] = "seeders = seeders - 1";
                                $updateset[] = "leechers = leechers + 1";
                        }
                }
        }
        else
        {
                if (portblacklisted($port))
                        err("Port $port is blacklisted.");
                else
                {
                        $sockres = @fsockopen($ip, $port, $errno, $errstr, 5);
                        if (!$sockres)
                                $connectable = "no";
                        else
                        {
                                $connectable = "yes";
                                @fclose($sockres);
                        }
                }

                $ret = mysql_query("INSERT INTO peers (connectable, torrent, peer_id, ip, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, agent, uploadoffset, downloadoffset, passkey) VALUES ('$connectable', $torrentid, " . sqlesc($peer_id) . ", " . sqlesc($ip) . ", $port, $uploaded, $downloaded, $left, NOW(), NOW(), '$seeder', $userid, " . sqlesc($agent) . ", $uploaded, $downloaded, $passkey)");
                if ($ret)
                {
                        if ($seeder == "yes")
                                $updateset[] = "seeders = seeders + 1";
                        else
                                $updateset[] = "leechers = leechers + 1";
                }
        }
}

if ($seeder == "yes")
{
        if ($torrent["banned"] != "yes")
                $updateset[] = "visible = 'yes'";
        $updateset[] = "last_action = NOW()";
}

if (count($updateset))
        mysql_query("UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $torrentid");

benc_resp_raw($resp);


?>

Upload.php
Code:

/*
// +--------------------------------------------------------------------------+
// | TorrentStrike X-Edition by Neptune                                      |
// +--------------------------------------------------------------------------+
// | This file is part of TorrentStrike X-Edtion. Is based on TBDev,          |
// | originally by RedBeard of TorrentBits, extensively modified by          |
// | Gartenzwerg.                                                            |
// |                                                                          |
// | TorrentStrike is free software; you can redistribute it and/or modify    |
// | it under the terms of the GNU General Public License as published by    |
// | the Free Software Foundation; either version 2 of the License, or        |
// | (at your option) any later version.                                      |
// |                                                                          |
// | TorrentStrike is distributed in the hope that it will be useful,        |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            |
// | GNU General Public License for more details.                            |
// |                                                                          |
// | You should have received a copy of the GNU General Public License        |
// | along with TorrentStrike; if not, write to the Free Software Foundation, |
// | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            |
// +--------------------------------------------------------------------------+
// |                                      TorrentStrike X-Edition by Neptune |
// +--------------------------------------------------------------------------+
*/
require_once("include/bittorrent.php");
loggedinorreturn();


if (get_user_class() < UC_UPLOADER)
        stderr("Sorry...", "You are not authorized to upload torrents. (See uploader application form.");
       
if ($CURUSER["uploadpos"] == 'no')
{
stdmsg("Sorry...", "You are not authorized to upload torrents.  (See Read Inbox)");
stdfoot();
exit;
}

loggedinorreturn();
parked();
stdhead("Upload");

?>





The tracker's announce url is



begin_frame("Upload",false,10,false);
begin_table(true);
tr("Torrent file", "\n", 1);
tr("Torrent name", "
(Taken from filename if not specified. Please use descriptive names.)\n", 1);
tr("Small Description", "
Small Description for the uploaded file (Example: A good movie!!!)
This Description is shown in browse.php under the Torrentname.", 1);
tr("Poster", "
(Direct link for a poster image to be shown on the details page)\n", 1);
tr("NFO file", "
(Optional. Can only be viewed by power users.)\n", 1);
tr("Description", "" .
  "
|HTML code is not allowed| |Click here to rip a NFO|", 1);

$s = "\n";

$sp = "\n";
tr("Requested", $sp, 1);
tr("Type", $s, 1);
//==== offer dropdown for offer mod  from code by S4NE
$res66 = mysql_query("SELECT id, name, allowed FROM offers WHERE userid = $CURUSER[id] ORDER BY name ASC") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res66) > 0) {
$offer = "";
tr("Offer", $offer."
 If you are uploading one of your offers please select it here so the voters will be notified." , 1);
}
//===end
?>

Neptune 25th April 2008 16:35

Re: Auto delete torrents
 
I use this announce.php in my tracker and Golden Torrents Mod works well (Only upload stats are recorded)!

Code:

/*
// +--------------------------------------------------------------------------+
// | TorrentStrike X-Edition by Neptune                                      |
// +--------------------------------------------------------------------------+
// | This file is part of TorrentStrike X-Edtion. Is based on TBDev,          |
// | originally by RedBeard of TorrentBits, extensively modified by          |
// | Gartenzwerg.                                                            |
// |                                                                          |
// | TorrentStrike is free software; you can redistribute it and/or modify    |
// | it under the terms of the GNU General Public License as published by    |
// | the Free Software Foundation; either version 2 of the License, or        |
// | (at your option) any later version.                                      |
// |                                                                          |
// | TorrentStrike is distributed in the hope that it will be useful,        |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            |
// | GNU General Public License for more details.                            |
// |                                                                          |
// | You should have received a copy of the GNU General Public License        |
// | along with TorrentStrike; if not, write to the Free Software Foundation, |
// | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            |
// +--------------------------------------------------------------------------+
// |                                      TorrentStrike X-Edition by Neptune |
// +--------------------------------------------------------------------------+
*/
ob_start("ob_gzhandler");

require_once("include/bittorrent.php");
require_once("include/benc.php");



function err($msg)
{
        benc_resp(array("failure reason" => array(type => "string", value => $msg)));
        exit();
}

function benc_resp($d)
{
        benc_resp_raw(benc(array(type => "dictionary", value => $d)));
}

function benc_resp_raw($x)
{
        header("Content-Type: text/plain");
        header("Pragma: no-cache");
        print($x);
}

$req = "info_hash:peer_id:!ip:port:uploaded:downloaded:left:!event:!passkey";
foreach (explode(":", $req) as $x)
{
        if ($x[0] == "!")
        {
                $x = substr($x, 1);
                $opt = 1;
        }
        else
                $opt = 0;
        if (!isset($_GET[$x]))
        {
                if (!$opt)
                        err("missing key");
                continue;
        }
        $GLOBALS[$x] = unesc($_GET[$x]);
}

if (ENA_PASSKEY && (
                strlen($passkey) != 32 &&
                @mysql_num_rows(@mysql_query("SELECT id FROM users WHERE passkey=" . sqlesc($passkey))) != 1))
        err("Invalid passkey! Re-download the .torrent from $BASEURL ($passkey)");
$passkey=sqlesc($passkey);       

foreach (array("info_hash","peer_id") as $x)
{
        if (strlen($GLOBALS[$x]) != 20)
                err("invalid $x (" . strlen($GLOBALS[$x]) . " - " . urlencode($GLOBALS[$x]) . ")");
}

//if (empty($ip) || !preg_match('/^(\d{1,3}\.){3}\d{1,3}$/s', $ip))
        $ip = getip();

$port = 0 + $port;
$downloaded = 0 + $downloaded;
$uploaded = 0 + $uploaded;
$left = 0 + $left;

$rsize = 50;
foreach(array("num want", "numwant", "num_want") as $k)
{
        if (isset($_GET[$k]))
        {
                $rsize = 0 + $_GET[$k];
                break;
        }
}

$agent = $_SERVER["HTTP_USER_AGENT"];

// Deny access made with a browser...
//if (ereg("^Mozilla\\/", $agent) || ereg("^Opera\\/", $agent) || ereg("^Links ", $agent) || ereg("^Lynx\\/", $agent))
//        err("torrent not registered with this tracker");

if (!$port || $port > 0xffff)
        err("invalid port");

if (!isset($event))
        $event = "";

$seeder = ($left == 0) ? "yes" : "no";


// Banned Clients - By Petr1fied
$filename = "include/banned_clients.txt";
if (filesize($filename)==0 || !file_exists($filename))
$banned_clients=array();
else
{
$handle = fopen($filename, "r");
$banned_clients = unserialize(fread($handle, filesize($filename)));
fclose($handle);
}

foreach($banned_clients as $k => $v)
{
if(substr(bin2hex($peer_id), 0, 16) == $v["peer_id"] || substr(bin2hex($peer_id), 0, 6) == $v["peer_id"])
{
$client_ban=array($v["client_name"], $v["reason"]);
}
}

if($client_ban)
err("I'm sorry, $client_ban[0] is banned from this tracker (".stripslashes($client_ban[1]).")");
// Banned Clients - By Petr1fied


$res = mysql_query("SELECT id, banned, free, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts FROM torrents WHERE " . hash_where("info_hash", $info_hash));

$torrent = mysql_fetch_assoc($res);
if (!$torrent)
        err("torrent not registered with this tracker");

$torrentid = $torrent["id"];

$fields = "seeder, peer_id, ip, port, uploaded, downloaded, userid, UNIX_TIMESTAMP(last_action) AS ts";

$numpeers = $torrent["numpeers"];
$limit = "";
if ($numpeers > $rsize)
        $limit = "ORDER BY RAND() LIMIT $rsize";
$res = mysql_query("SELECT $fields FROM peers WHERE torrent = $torrentid AND connectable = 'yes' $limit");

$resp = 'd' . benc_str('interval') . 'i' . $announce_interval . 'e' . benc_str('peers') . (($compact = ($_GET['compact'] == 1))?'':'l');
unset($self);
while ($row = mysql_fetch_assoc($res))
{
        $row["peer_id"] = hash_pad($row["peer_id"]);

        if ($row["peer_id"] === $peer_id)
        {
                $userid = $row["userid"];
                $self = $row;
                continue;
        }
        if($compact)
        {
                $peer_ip = explode('.', $row["ip"]);
                $plist .= pack("C*", $peer_ip[0], $peer_ip[1], $peer_ip[2], $peer_ip[3]). pack("n*", (int)$row["port"]);
        } else {
                $resp .= "d" .
                benc_str("ip") . benc_str($row["ip"]) .
                benc_str("peer id") . benc_str($row["peer_id"]) .
                benc_str("port") . "i" . $row["port"] . "e" .
                "e";
        }
}

$resp .= ($compact ? benc_str($plist):''). "ee";

$selfwhere = "torrent = $torrentid AND ". (ENA_PASSKEY ?"passkey=$passkey AND ":'') . hash_where("peer_id", $peer_id);

if (!isset($self))
{
        $res = mysql_query("SELECT $fields FROM peers WHERE $selfwhere");
        $row = mysql_fetch_assoc($res);
        if ($row)
        {
                $userid = $row["userid"];
                $self = $row;
        }
}


//// Up/down stats ////////////////////////////////////////////////////////////

if (!isset($self))
{
        if(ENA_PASSKEY && ENA_PASSKEYLIMITCONNECTIONS)
        {
                $valid = @mysql_num_rows(@mysql_query("SELECT id FROM peers WHERE torrent=$torrentid AND passkey=$passkey"));
                if ($valid[0] >= 1 && $seeder == 'no')
                        err("Connection limit exceeded! You may only leech from one location at a time.");
                if ($valid[0] >= 3 && $seeder == 'yes')
                        err("Connection limit exceeded!");
        }
        $rz = mysql_query("SELECT id, uploaded, downloaded, class FROM users WHERE ip='$ip' AND enabled = 'yes' ". (ENA_PASSKEY ? "AND passkey=$passkey ":''). "ORDER BY last_access DESC LIMIT 1") or err("Tracker error 2");
        if ($MEMBERSONLY && mysql_num_rows($rz) == 0)
                err("Unrecognized host ($ip). Please go to $BASEURL to sign-up or login.");
        $az = mysql_fetch_assoc($rz);
        $userid = $az["id"];

//        if ($left > 0 && $az["class"] < UC_VIP)
        if ($az["class"] < UC_VIP)
        {
                $gigs = $az["uploaded"] / (1024*1024*1024);
                $elapsed = floor((gmtime() - $torrent["ts"]) / 3600);
                $ratio = (($az["downloaded"] > 0) ? ($az["uploaded"] / $az["downloaded"]) : 1);
                if ($ratio < 0.5 || $gigs < 5) $wait = 48;
                elseif ($ratio < 0.65 || $gigs < 6.5) $wait = 24;
                elseif ($ratio < 0.8 || $gigs < 8) $wait = 12;
                elseif ($ratio < 0.95 || $gigs < 9.5) $wait = 6;
                else $wait = 0;
                if (($elapsed < $wait)&&($seeder == 'no'))
                                err("Not authorized (" . ($wait - $elapsed) . "h) - READ THE FAQ!");
        }
}
else
{
       
// Get the last uploaded amount from user account for reference and store it in $last_up
    $rst = mysql_query("SELECT class, uploaded FROM users WHERE id = $userid") or err("Tracker error 5");
    $art = mysql_fetch_array($rst);
    $last_up = $art["uploaded"];
    $class = $art["class"];
       
        $upthis = max(0, $uploaded - $self["uploaded"]);
        $downthis = max(0, $downloaded - $self["downloaded"]);

            if ($upthis > 0 || $downthis > 0)
        mysql_query("UPDATE users SET uploaded = uploaded + $upthis". ($torrent['free']=='no'?", downloaded = downloaded + $downthis ":' '). "WHERE id=$userid") or err("Tracker error 3");
}

// Initial sanity check xMB/s for 1 second
    if($upthis > 2097152)
    {
        //Work out time difference
        $endtime = time();
        $starttime = $self['ts'];
        $diff = ($endtime - $starttime);
        //Normalise to prevent divide by zero.
        $rate = ($upthis / ($diff + 1));
        //Currently 2MB/s. Increase to 5MB/s once finished testing.
        if ($rate > 2097152)
        {
            if ($class < UC_MODERATOR)
            {
                $rate = mksize($rate);
                $client = $agent;
                $userip = getip();

                auto_enter_cheater($userid, $rate, $upthis, $diff, $torrentid, $client, $userip, $last_up);
            }
        }
    }

///////////////////////////////////////////////////////////////////////////////

function portblacklisted($port)
{
        // direct connect
        if ($port >= 411 && $port <= 413) return true;

        // bittorrent
        if ($port >= 6881 && $port <= 6889) return true;

        // kazaa
        if ($port == 1214) return true;

        // gnutella
        if ($port >= 6346 && $port <= 6347) return true;

        // emule
        if ($port == 4662) return true;

        // winmx
        if ($port == 6699) return true;

        return false;
}

$updateset = array();

if ($event == "stopped")
{
        if (isset($self))
       
        {
                mysql_query("DELETE FROM peers WHERE $selfwhere");
                if (mysql_affected_rows())
                {
                        if ($self["seeder"] == "yes")
                                $updateset[] = "seeders = seeders - 1";
                        else
                                $updateset[] = "leechers = leechers - 1";
                }
        }
}
else
{
        if ($event == "completed")
                $updateset[] = "times_completed = times_completed + 1";

        if (isset($self))
        {
                mysql_query("UPDATE peers SET uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = NOW(), seeder = '$seeder'"
                        . ($seeder == "yes" && $self["seeder"] != $seeder ? ", finishedat = " . time() : "") . " WHERE $selfwhere");
                if (mysql_affected_rows() && $self["seeder"] != $seeder)
                {
                        if ($seeder == "yes")
                        {
                                $updateset[] = "seeders = seeders + 1";
                                $updateset[] = "leechers = leechers - 1";
                        }
                        else
                        {
                                $updateset[] = "seeders = seeders - 1";
                                $updateset[] = "leechers = leechers + 1";
                        }
                }
        }
        else
        {
                if (portblacklisted($port))
                        err("Port $port is blacklisted.");
                else
                {
                        $sockres = @fsockopen($ip, $port, $errno, $errstr, 5);
                        if (!$sockres)
                                $connectable = "no";
                        else
                        {
                                $connectable = "yes";
                                @fclose($sockres);
                        }
                }

                $ret = mysql_query("INSERT INTO peers (connectable, torrent, peer_id, ip, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, agent, uploadoffset, downloadoffset, passkey) VALUES ('$connectable', $torrentid, " . sqlesc($peer_id) . ", " . sqlesc($ip) . ", $port, $uploaded, $downloaded, $left, NOW(), NOW(), '$seeder', $userid, " . sqlesc($agent) . ", $uploaded, $downloaded, $passkey)");
                if ($ret)
                {
                        if ($seeder == "yes")
                                $updateset[] = "seeders = seeders + 1";
                        else
                                $updateset[] = "leechers = leechers + 1";
                }
        }
}

if ($seeder == "yes")
{
        if ($torrent["banned"] != "yes")
                $updateset[] = "visible = 'yes'";
        $updateset[] = "last_action = NOW()";
}

if (count($updateset))
        mysql_query("UPDATE torrents SET " . join(",", $updateset) . " WHERE id = $torrentid");

benc_resp_raw($resp);


?>

and in upload.php

change
Code:

UC_UPLOADER
to
Code:

UC_VIP

Swompen 25th April 2008 20:09

Re: Auto delete torrents
 
thank you

Swompen 25th April 2008 23:16

Re: Auto delete torrents
 
Ok, 1 more thing, every time i use a " i get \ in front of it, how to fix that?


All times are GMT +2. The time now is 06:23.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.