<?php
/*
*----------------------------phpMyBitTorrent V 2.0-beta3-----------------------*
*--- The Ultimate BitTorrent Tracker and BMS (Bittorrent Management System) ---*
*--------------   Created By Antonio Anzivino (aka DJ Echelon)   --------------*
*-------------               http://www.p2pmania.it               -------------*
*------------ Based on the Bit Torrent Protocol made by Bram Cohen ------------*
*-------------              http://www.bittorrent.com             -------------*
*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*
*--   This program 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.                                    --*
*--                                                                          --*
*--   This program 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 this program; if not, write to the Free Software            --*
*-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA --*
*--                                                                          --*
*------------------------------------------------------------------------------*
*------              ©2005 phpMyBitTorrent Development Team              ------*
*-----------               http://phpmybittorrent.com               -----------*
*------------------------------------------------------------------------------*
*-----------------   Sunday, September 14, 2008 9:05 PM   ---------------------*
*/

error_reporting(E_NONE);

if (eregi("cleanup.php", $_SERVER['SCRIPT_NAME'])) die("You can't access this file directly");

if ($autoscrape) require_once("include/bdecoder.php");

function autoinvites($length, $minlimit, $maxlimit, $minratio, $invites)
       {
	   global $db, $db_prefix;
	$minlimit = $minlimit*1024*1024*1024;
	$maxlimit = $maxlimit*1024*1024*1024;
	$res = $db->sql_query("SELECT id, invites FROM ".$db_prefix."_users WHERE  active = 1 AND downloaded >= $minlimit AND downloaded < $maxlimit AND uploaded / downloaded >= $minratio AND warned = '0' AND invites < 10 AND UNIX_TIMESTAMP(invitedate) < UNIX_TIMESTAMP(NOW()) - $length*86400") ;
if ($db->sql_numrows($res) > 0)
    {
        while ($arr = $db->sql_fetchrow($res))
        {
if ($arr[invites] == 9)
$invites = 1;
elseif ($arr[invites] == 8 && $invites == 3)
$invites = 2;
  $db->sql_query("UPDATE ".$db_prefix."_users SET invites = invites + ".$invites.", invitedate = NOW() WHERE id='".$arr['id']."'") ; 
 }
}
}
function getscrapedata($url) {
        if (!$fp = fopen($url,"rb")) return false; //Warnings are shown
        $page = "";
        while (!feof($fp)) $page .= @fread($fp,10000);
        @fclose($fp);

        ////echo $page;

        $scrape = BDecode($page,"Scrape");
        unset($page);

        if (!$scrape) return false;

        return $scrape;
}

function ResolveTracker($url, &$resp) {
        $server = parse_url($url);

        if (!$server["port"]) $server["port"] = 80;

        $out  = "GET ".$server["path"]." HTTP/1.1\r\n";
        $out .= "Host: ".$server['host']."\r\n";
        $out .= "User-Agent: Azureus 2.4.0.2\r\n";
        $out .= "Connection: Close\r\n\r\n";

        $fp = @fsockopen($server["host"],$server["port"],$errno,$errstr,1.0);
        if (!$fp) {
                //echo "Debug: Il tracker non risponde";
                return false;
        }

        fwrite($fp,$out);
        $resp = fgets($fp,512);
        fclose($fp);
        //echo $resp;
        if(!ereg("HTTP/1\.[01] 20[0-3] OK",$resp)) return false;
        return true;
}

function multiscrape() {
        //echo "Debug: entro in multiscrape\n";
        global $db, $db_prefix, $time_tracker_update;
        $sql = "SELECT url, support, id support FROM ".$db_prefix."_trackers WHERE UNIX_TIMESTAMP(updated) < UNIX_TIMESTAMP(NOW()) - (".intval($time_tracker_update).") AND status = 'active' ORDER BY updated ASC LIMIT 1;";
        $trkres = $db->sql_query($sql);
        if (!$trkrow = $db->sql_fetchrow($trkres)) {
                //echo "Debug: Non ho un tracker attivo\n";
                $db->sql_freeresult($trkres);
                //Trying to contact a dead tracker after thrice the interval
                $sql = "SELECT url, support, id FROM ".$db_prefix."_trackers WHERE UNIX_TIMESTAMP(updated) < UNIX_TIMESTAMP(NOW()) - (3 * ".intval($time_tracker_update).") AND status = 'offline' ORDER BY RAND() LIMIT 1;";
                $trkres = $db->sql_query($sql);
                if (!$trkrow = $db->sql_fetchrow($trkres)) return;
        }
        $db->sql_freeresult($trkres);
        $announce = $trkrow["url"];
        $support = $trkrow["support"];
		$id = $trkrow['id'];

        $sql = "SELECT info_hash FROM ".$db_prefix."_torrents WHERE tracker = '".$announce."';";
        $hashres = $db->sql_query($sql);

        if ($db->sql_numrows($hashres) < 1) {
                $db->sql_query("DELETE FROM ".$db_prefix."_trackers WHERE url = '".$announce."';");
                return;
        }

        $infohashes = Array();
        while ($row_hash = $db->sql_fetchrow($hashres)) {
                $infohashes[] = $row_hash["info_hash"];
        }
        unset($row_hash, $sql);
        $db->sql_freeresult($hashres);

        //echo "Debug: ho scelto un tracker: ".$announce."\n";
        $scrapeurl = str_replace("announce","scrape",$announce);
        /*
        0TH ATTEMPT: CHECK FOR TRACKER ONLINE
        1ST ATTEMPT: SELECTIVE SCRAPE
        2ND ATTEMPT: GLOBAL SCRAPE
        3RD ATTEMPT: SINGLE SCRAPE
        */
        if (!ResolveTracker($scrapeurl, $resp)) {
                //echo "Debug: Impossibile collegarsi al tracker\n";
                if ($resp) //echo $resp;
                $sql = "UPDATE ".$db_prefix."_trackers SET status = 'dead' WHERE url = '".addslashes($announce)."';";
                $db->sql_query($sql);
                $sql = "UPDATE ".$db_prefix."_torrents SET seeders = 0, leechers = 0, tot_peer = 0 WHERE tracker = '". addslashes($announce) . "';";
                $db->sql_query($sql);
                return;
        }

        //echo "Debug: il tracker è pronto\n";

        if ($support == "selective") {
                //echo "Debug: Tento il selettivo\n";
                /*
                TRIES SELECTIVE SCRAPE.
                IF WORKS SAVES DATA AND TERMINATES BLOCK (WITH BREAK)
                ELSE TRIES GLOBAL SCRAPE (WHICH IS A *STANDARD*)
                */
                $url = $scrapeurl.((strpos($scrape_url,"?")) ? "&" : "?")."info_hash=".urlencode($infohashes[0]);
                for ($i = 1; $i < count($infohashes); $i++) {
                        $url .= "&info_hash=".urlencode($infohashes[$i]);

                }
                $scrape = getscrapedata($url);
                $scrape_valid = false;

                //Checking if returned scrape is valid scrape data
                if ($scrape) {
                        if (!entry_exists($scrape,"failure reason(String)","Scrape") AND entry_exists($scrape,"files(Dictionary)","Scrape")) {
                                $scrape_valid = true;
                        }
                }

                if (!$scrape_valid) {
                        $support = "global";
                        $db->sql_query("UPDATE ".$db_prefix."_trackers SET support = 'global' WHERE id = '".$id."';");
                }
        }

        if ($support == "global" AND count($infohashes) > 1) {
                //echo "Debug: Tento il globale\n";
                $scrape_valid = false;
                $scrape = getscrapedata($scrapeurl);
                if ($scrape) {
                        if (!entry_exists($scrape,"failure reason(String)","Scrape") AND entry_exists($scrape,"files(Dictionary)","Scrape")) {
                                $scrape_valid = true;
                        }
                }
                if (!$scrape_valid) {
                        $support = "single";
                        $db->sql_query("UPDATE ".$db_prefix."_trackers SET support = 'single' WHERE id = '".$id."';");
                }
        }

        if ($support == "single" OR count($infohashes) == 1) {
                //echo "Debug: Tento il singolo\n";

                /*
                SINGLE SCRAPE CREATES A FAKE GLOBAL SCRAPE QUERYING THE TRACKER MULTIPLE TIMES
                THE FAKE SCRAPE IS USED TO MAKE THE NEXT PART OF THE CODE BELIEVE WE DID A SINGLE JOB
                THIS METHOD IS USED ON LARGE TRACKERS AND HAS ONE INCONVENIENT: WITH MANY TORRENTS
                YOUR SERVER COULD GET BANNED FOR HAMMERING
                */

                $scrape = domxml_new_doc("1.0");
                $root = $scrape->create_element("Scrape");
                $root->set_attribute("type","Dictionary");
                $files = $scrape->create_element("files");
                $files->set_attribute("type","Dictionary");

                foreach ($infohashes as $hash) {
                        $scr = getscrapedata ($scrapeurl.((strpos($scrape_url,"?")) ? "&" : "?")."info_hash=".urlencode($hash));
                        $hash_hex = preg_replace_callback('/./s', "hex_esc", str_pad($hash,20));
						$hash_hex = 'a'.$hash_hex;

                        if (entry_exists($scr,"files/".$hash_hex."(Dictionary)","Scrape")) {
                                #Create the XML node for fake global scrape
                                $item = $scrape->create_element($hash_hex);
                                $item->set_attribute("type","Dictionary");

                                $complete = $scrape->create_element("complete");
                                $complete->set_attribute("type","Integer");
                                $child = $scrape->create_text_node(entry_read($scr,"files/".$hash_hex."/complete(Integer)","Scrape"));
                                $complete->append_child($child);

                                $incomplete = $scrape->create_element("incomplete");
                                $incomplete->set_attribute("type","Integer");
                                $child = $scrape->create_text_node(entry_read($scr,"files/".$hash_hex."/incomplete(Integer)","Scrape"));
                                $incomplete->append_child($child);

                                $downloaded = $scrape->create_element("downloaded");
                                $downloaded->set_attribute("type","Integer");
                                $child = $scrape->create_text_node(entry_read($scr,"files/".$hash_hex."/downloaded(Integer)","Scrape"));
                                $downloaded->append_child($child);

                                $item->append_child($complete);
                                $item->append_child($incomplete);
                                $item->append_child($downloaded);

                                $files->append_child($item);
                        }
                        unset($scr);

                        ob_flush();
                        sleep(2);
                }

                $root->append_child($files);
                $scrape->append_child($root);

        }

        //echo "Debug: Ho fatto lo scrape\n";
        foreach ($infohashes as $hash) {
                $hash_hex = preg_replace_callback('/./s', "hex_esc", str_pad($hash,20));
				$hash_hex = 'a'.$hash_hex;
                if (!entry_exists($scrape,"files/".$hash_hex."(Dictionary)","Scrape")) {
                        $seed = $leech = $completed = 0;
                } else {

                        $seed = entry_read($scrape,"files/".$hash_hex."/complete(Integer)","Scrape");
                        $leech = entry_read($scrape,"files/".$hash_hex."/incomplete(Integer)","Scrape");
                        $completed = entry_read($scrape,"files/".$hash_hex."/downloaded(Integer)","Scrape");
                        $name = ((entry_exists($scrape,"files/".$hash_hex."/name(String)","Scrape")) ? entry_read($scrape,"files/".$hash_hex."/name(String)","Scrape") : "");
                }
                if (($seed + $leech) > 0) $visible = "yes";
                else $visible = "no";
                $sql = "UPDATE ".$db_prefix."_torrents SET seeders = ". $seed .", leechers = ".$leech.", tot_peer = ". ($seed + $leech) .", completed = ". $completed .", visible = '".$visible."', last_action = NOW() WHERE info_hash = '".addslashes($hash)."';";
                $db->sql_query($sql);
        }
        unset($scrape);
        $db->sql_query("UPDATE ".$db_prefix."_trackers SET updated = NOW(), status = 'active' WHERE id = '".$id."';");

        //echo "Debug: Scrape completato\n";

}

function cleanup() {
        global $db, $db_prefix, $btuser, $autoscrape, $dead_torrent_interval, $announce_interval, $down_limit;

        $db->sql_query("DELETE FROM ".$db_prefix."_download WHERE date < SUBDATE(SYSDATE(), INTERVAL 7 DAY);");
        $db->sql_query("DELETE FROM ".$db_prefix."_users WHERE active = 0 AND UNIX_TIMESTAMP(regdate) < UNIX_TIMESTAMP(NOW()) - 86400;");

        $sql = "DELETE FROM ".$db_prefix."_peers WHERE UNIX_TIMESTAMP(last_action) < UNIX_TIMESTAMP(NOW()) - ".($announce_interval+60).";"; //One minute of tolerance
        $res = $db->sql_query($sql);

        #Reset Statistics. Run where there is a dead peer
        if ($db->sql_affectedrows($res) > 0) {
                $db->sql_query("UPDATE ".$db_prefix."_torrents SET seeders = 0, leechers = 0, tot_peer = 0, speed = 0 WHERE tracker IS NULL OR backup_tracker = 'true';");

                $sql = "SELECT COUNT(*) AS tot, torrent, seeder, SUM(upload_speed) AS speed FROM ".$db_prefix."_peers GROUP BY torrent, seeder;";
                $res = $db->sql_query($sql);
                while($row = $db->sql_fetchrow($res)) {
                        if ($row["seeder"] == "yes") $sql = "UPDATE ".$db_prefix."_torrents SET seeders = '".$row["tot"]."', speed = speed + '".$row["speed"]."' WHERE id='".$row["torrent"]."';";
                        else $sql = "UPDATE ".$db_prefix."_torrents SET leechers = '".$row["tot"]."', speed = speed + '".$row["speed"]."' WHERE id='".$row["torrent"]."';";
                        $db->sql_query($sql);
                }

                $db->sql_query("UPDATE ".$db_prefix."_torrents SET tot_peer = seeders + leechers;");
        }
        $db->sql_query("UPDATE ".$db_prefix."_torrents SET evidence = 0 WHERE evidence = 1 AND UNIX_TIMESTAMP(added) < UNIX_TIMESTAMP(NOW()) - 14*84600;");
        $db->sql_query("UPDATE ".$db_prefix."_torrents SET visible = 'no' WHERE type != 'link' AND tot_peer <= '".$down_limit."' AND UNIX_TIMESTAMP(last_action) < UNIX_TIMESTAMP(NOW()) - ".intval($dead_torrent_interval)." AND evidence != 1 AND (TRACKER IS NULL OR ".intval($autoscrape).");");
        $db->sql_query("UPDATE ".$db_prefix."_torrents SET visible = 'yes' WHERE tot_peer > '".$down_limit."';");

        #Clean Shoutbox after 8 hours
        $db->sql_query("DELETE FROM ".$db_prefix."_shouts WHERE UNIX_TIMESTAMP(posted) < UNIX_TIMESTAMP(NOW()) - (8 * 60 * 60);");

        #Clean online user list after 10 minutes of inactivity
        $db->sql_query("DELETE FROM ".$db_prefix."_online_users WHERE UNIX_TIMESTAMP(last_action) < UNIX_TIMESTAMP(NOW()) - 600;");

$res = $db->sql_query("SELECT * FROM ".$db_prefix."_lottery_config") ;
while ($arr = $db->sql_fetchrow($res))
$arr_config[$arr['name']] = $arr['value'];

if ($arr_config['enable'] == 1)
{
if (gmdate("Y-m-d H:i:s", time()) > $arr_config['end_date'])
{
if ($arr_config["ticket_amount_type"] == GB)
$arr_config['ticket_amount'] = 1024 * 1024 * 1024 * $arr_config['ticket_amount'];
else if ($arr_config["ticket_amount_type"] == MB)
$arr_config['ticket_amount'] = 1024 * 1024 * $arr_config['ticket_amount'];
$size = $arr_config['ticket_amount'];

if ($arr_config["ticket_amount_type"] == GB)
$arr_config['prize_fund'] = 1024 * 1024 * 1024 * $arr_config['prize_fund'];
else if ($arr_config["ticket_amount_type"] == MB)
$arr_config['prize_fund'] = 1024 * 1024 * $arr_config['prize_fund'];
$prize_fund = $arr_config['prize_fund'];

$total = $db->sql_numrows($db->sql_query("SELECT * FROM ".$db_prefix."_tickets"));
if ($arr_config["use_prize_fund"])
{
$pot = $prize_fund / $arr_config['total_winners'];
$res = $db->sql_query("SELECT user FROM ".$db_prefix."_tickets ORDER BY RAND() LIMIT $arr_config[total_winners]") ;
$who_won = array();
$msg = "Congratulations, You have won: <b>".mksize($pot)."</b>.<br /><br />This has been added to your upload amount<br /><br />Thanks for playing Lottery.";
while ($arr = $db->sql_fetchrow($res))
{
$res2 = $db->sql_query("SELECT modcomment FROM ".$db_prefix."_users WHERE id = $arr[user]") ;
$arr2 = $db->sql_fetchrow($res2);
$modcomment = $arr2['modcomment'];
$modcom = "User won the lottery: " . mksize($pot) . " at " . gmdate("Y-m-d H:i:s", time()) . "\n" . $modcomment;
$db->sql_query("UPDATE ".$db_prefix."_users SET uploaded = uploaded + $pot, modcomment = '".$modcom."' WHERE id = $arr[user]") ;
$db->sql_query("INSERT INTO ".$db_prefix."_private_messages (sender, recipient, subject, text, sent) VALUES('1', '".$arr['user']."', 'LOTTERY', '".$msg."', NOW())") ;
$who_won[] = $arr['user'];
}
}
else
{
$pot = $total * $size / $arr_config['total_winners'];
$res = $db->sql_query("SELECT user FROM ".$db_prefix."_tickets ORDER BY RAND() LIMIT $arr_config[total_winners]") ;
$who_won = array();
$msg = "Congratulations, You have won: <b>".mksize($pot)."</b>.<br /><br />This has been added to your upload amount<br /><br />Thanks for playing Lottery.";
while ($arr = $db->sql_fetchrow($res))
{
$res2 = $db->sql_query("SELECT modcomment FROM ".$db_prefix."_users WHERE id = $arr[user]") ;
$arr2 = $db->sql_fetchrow($res2);
$modcomment = $arr2['modcomment'];
$modcom = "User won the lottery: " . mksize($pot) . " at " . gmdate("Y-m-d H:i:s", time()) . "\n" . $modcomment;
$db->sql_query("UPDATE ".$db_prefix."_users SET uploaded = uploaded + $pot, modcomment = '".$modcom."' WHERE id = $arr[user]") ;
$db->sql_query("INSERT INTO ".$db_prefix."_private_messages (sender, recipient, subject, text, sent) VALUES('1', '".$arr['user']."', 'LOTTERY', '".$msg."', NOW())") ;
$who_won[] = $arr['user'];
}
}
$who_won = implode("|", $who_won);
$who_won_date = gmdate("Y-m-d H:i:s", time());
$who_won_prize = $pot;
$db->sql_query("TRUNCATE TABLE ".$db_prefix."_tickets") ;
if ($who_won != '')
{
$db->sql_query("UPDATE ".$db_prefix."_lottery_config SET value = '$who_won' WHERE name = 'lottery_winners'") ;
$db->sql_query("UPDATE ".$db_prefix."_lottery_config SET value = '$who_won_prize' WHERE name = 'lottery_winners_amount'") ;
$db->sql_query("UPDATE ".$db_prefix."_lottery_config SET value = '$who_won_date' WHERE name = 'lottery_winners_time'") ;
}
$db->sql_query("UPDATE ".$db_prefix."_lottery_config SET value = '0' WHERE name = 'enable'") ;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                    TRYS CASINO                                                                   //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   $hours = 1; // Hours to wait after using all tries, until they will be restarted
   $sql = $db->sql_query("SELECT userid, trys, date, enableplay FROM ".$db_prefix."_casino WHERE UNIX_TIMESTAMP(date) < UNIX_TIMESTAMP(NOW()) - $hours*3600 AND trys >= '0' AND enableplay = 'yes'");
   while ($arr = $db->sql_fetchrow($res))
   {
       $db->sql_query("UPDATE ".$db_prefix."_casino SET trys='0' WHERE userid='".$arr['userid']."'");
   }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                    TRYS CASINO                                                                //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                        EFFACEMENT DES VIEILLES REQUETES                                                        //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $hours = 720; // Hours to keep no filled requests 720=30days, 30*24=720
    $res = $db->sql_query("SELECT id, userid, request, descr, added, hits, cat, filled, filledby FROM ".$db_prefix."_requests WHERE UNIX_TIMESTAMP(added) < UNIX_TIMESTAMP(NOW()) - $hours*3600") ;
    while ($arr = $db->sql_fetchrow($res))
    {
$db->sql_query("DELETE FROM ".$db_prefix."_requests WHERE id=$arr[id]") ;
$db->sql_query("DELETE FROM ".$db_prefix."_addedrequests WHERE id=$arr[id]") ;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                      FIN EFFACEMENT DES VIEILLES REQUETES                                                      //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                      EFFACEMENT DES PROPOSITIONS UPLOAD                                                        //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $hours = 360; // Hours to keep offers 360=15days, 15*24=360
	$jours = ($hours/24);
    $res = $db->sql_query("SELECT id, name, userid FROM ".$db_prefix."_offers WHERE UNIX_TIMESTAMP(added) < UNIX_TIMESTAMP(NOW()) - $hours*3600");
    while ($arr = $db->sql_fetchrow($res))
    {
     $db->sql_query("DELETE FROM ".$db_prefix."_offers WHERE id=$arr[id]") ;
     $db->sql_query("DELETE FROM ".$db_prefix."_offervotes WHERE offerid=$arr[id]") ;
	 $db->sql_query("UPDATE ".$db_prefix."_users SET seedbonus = seedbonus - '10.0' WHERE id = $arr[userid]") ;
  	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                     FIN EFFACEMENT DES PROPOSITIONS UPLOAD                                                     //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//die();

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                            FLASHSCORES                                                           //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $hours = 720; // Hours to keep MPS 720=30 days, 720/24=30
    $res =$db->sql_query("SELECT ID, game, user, level, score, date FROM ".$db_prefix."_flashscores WHERE UNIX_TIMESTAMP(date) < UNIX_TIMESTAMP(NOW()) - $hours*3600");
    while ($arr = $db->sql_fetchrow($res))
    {
        $db->sql_query("DELETE FROM ".$db_prefix."_flashscores WHERE date < $dt");
	}
	
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                          FLASHSCORES                                                         //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//SET INVITE AMOUNTS ACCORDING TO RATIO/GIGS ETC
autoinvites(10,1,4,.90,1);
autoinvites(10,4,7,.95,2);
autoinvites(10,7,10,1.00,3);
autoinvites(10,10,100000,1.05,4);
//END INVITES
        if ($autoscrape) multiscrape();
		autoclean();

}
register_shutdown_function("cleanup");
?>
