<? require_once("include/benc.php"); require_once("include/bittorrent.php"); require "rconpasswords.php"; hit_start(); function bark($msg) { genbark($msg, "Upload failed!"); } dbconn(); hit_count(); loggedinorreturn(); /* if (get_user_class() < UC_UPLOADER) die; */ bark("missing form data"); } bark("missing form data"); $f = $_FILES["file"]; $fname = unesc($f["name"]); bark("Empty filename!"); /* $nfofile = $_FILES['nfo']; if ($nfofile['name'] == '') bark("No NFO!"); if ($nfofile['size'] == 0) bark("0-byte NFO"); if ($nfofile['size'] > 65535) bark("NFO is too big! Max 65,535 bytes."); $nfofilename = $nfofile['tmp_name']; if (@!is_uploaded_file($nfofilename)) bark("NFO upload failed"); */ $descr = unesc($_POST["descr"]); if (!$descr) bark("You must enter a description!"); $catid = (0 + $_POST["type"]); if (!is_valid_id($catid)) bark("You must select a category to put the torrent in!"); if (!validfilename($fname)) bark("Invalid filename!"); bark("Invalid filename (not a .torrent)."); $shortfname = $torrent = $matches[1]; $torrent = unesc($_POST["name"]); $tmpname = $f["tmp_name"]; bark("eek"); bark("Empty file!"); $dict = bdec_file($tmpname, $max_torrent_size); bark("What the hell did you upload? This is not a bencoded file!"); function dict_check($d, $s) { if ($d["type"] != "dictionary") bark("not a dictionary"); $dd = $d["value"]; foreach ($a as $k) { $k = $m[1]; $t = $m[2]; } bark("dictionary is missing key(s)"); if ($dd[$k]["type"] != $t) bark("invalid entry in dictionary"); $ret[] = $dd[$k]["value"]; } else $ret[] = $dd[$k]; } return $ret; } function dict_get($d, $k, $t) { if ($d["type"] != "dictionary") bark("not a dictionary"); $dd = $d["value"]; return; $v = $dd[$k]; if ($v["type"] != $t) bark("invalid dictionary entry type"); return $v["value"]; } list($ann, $info) = dict_check($dict, "announce(string):info"); list($dname, $plen, $pieces) = dict_check($info, "name(string):piece length(integer):pieces(string)"); /* if (!in_array($ann, $announce_urls, 1)) bark("Sory ale po³ykam tylko torrenty na moim trackerze przezucac z innych stron
niestety nie mozna :( <b>" . $announce_urls[0] . "</b>"); */ bark("invalid pieces"); $totallen = dict_get($info, "length", "integer"); $type = "single"; } else { $flist = dict_get($info, "files", "list"); bark("missing both length and files"); bark("no files"); $totallen = 0; foreach ($flist as $fn) { list($ll, $ff) = dict_check($fn, "length(integer):path(list)"); $totallen += $ll; foreach ($ff as $ffe) { if ($ffe["type"] != "string") bark("filename error"); $ffa[] = $ffe["value"]; } bark("filename error"); } $type = "multi"; } // Replace punctuation characters with spaces $html = $_POST["html"]; $nfofile = $_FILES['nfo']; if ($nfofile['size'] > 65535) bark("NFO is too big! Max 65,535 bytes."); $nfofilename = $nfofile['tmp_name']; else $nfo = "''"; $img=$_FILES['img']['name']; $ret = mysql_query("INSERT INTO torrents (search_text, filename, owner, visible, info_hash, name, size, numfiles, typ
e, descr, ori_descr, category, save_as, added, last_action, nfo, image) VALUES (" . ", '" . get_date_time() . "', '" . get_date_time() . "', $nfo, '$img' )"); if (!$ret) { bark("torrent already uploaded!"); } foreach ($filelist as $file) { @mysql_query("INSERT INTO files (torrent, filename, size) VALUES ($id, ".sqlesc($file[0]).",".$file[1].")"); } $img=$_FILES['img']['name']; $imgtmp=$_FILES['img']['tmp_name']; write_log("Torrent $id ($torrent) was uploaded by " . $CURUSER["username"]); /* Game server notif */ /* RSS feeds */ { $cats = ""; $cats[$arr["id"]] = $arr["name"]; $s = "<?xml version="1.0" encoding="iso-8859-1" ?>n<rss version="0.91">n<channel>n" . "<title>TorrentBits</title>n<description>0-week torrents</description>n<link>$DEFAULTBASEURL/</link>n"; $r = mysql_query("SELECT id,name,descr,filename,category FROM torrents ORDER BY added DESC LI
MIT 15") or sqlerr(__FILE__, __LINE__); { $cat = $cats[$a["category"]]; } $s = "</channel>n</rss>n"; } /* Email notifs */ /******************* $res = mysql_query("SELECT name FROM categories WHERE id=$catid") or sqlerr(); $arr = mysql_fetch_assoc($res); $cat = $arr["name"]; $res = mysql_query("SELECT email FROM users WHERE enabled='yes' AND notifs LIKE '%[cat$catid]%'") or sqlerr(); $uploader = $CURUSER['username']; $size = mksize($totallen); $description = ($html ? strip_tags($descr) : $descr); $body = <<<EOD A new torrent has been uploaded. Name: $torrent Size: $size Category: $cat Uploaded by: $uploader Description ------------------------------------------------------------------------------- $description ------------------------------------------------------------------------------- You can use the URL below to download the torrent (you may have to login). $DEFAULTBASEURL/details.php?id=$id&hit=1 -- $SITENAME EOD; $to = ""; $nmax = 100; // Max recipients per message $nthis = 0; $ntotal = 0; $total = mysql_num_rows($res); while ($arr = mysql_fetch_row($res)) { if ($nthis == 0) $to = $arr[0]; else $to .= "," . $arr[0]; ++$nthis; ++$ntotal; if ($nthis == $nmax || $ntotal == $total) { if (!mail("Multiple recipients <$SITEEMAIL>", "New torrent - $torrent", $body, "From: $SITEEMAILrnBcc: $to", "-f$SITEEMAIL")) stderr("Error", "Your torrent has been been uploaded. DO NOT RELOAD THE PAGE!n" . "There was however a problem delivering the e-mail notifcations.n" . "Please let an administrator know about this error!n"); $nthis = 0; } } *******************/ hit_end(); ?>
---

tiraeth