// SEEDED, LETS MAKE IT VISIBLE THEN
if ($seeder == "yes") {
if ($torrent["banned"] != "yes") // DONT MAKE BANNED ONES VISIBLE
$updateset[] = "visible = 'yes'";
$updateset[] = "last_action = '".get_date_time()."'";
}
// NOW WE UPDATE THE TORRENT AS PER ABOVE
// if (is_countable($updateset) && count($updateset))
// SQL_Query_exec("UPDATE torrents SET " . join(",", $updateset) . " WHERE id=$torrentid");
// if (count($updateset))
// SQL_Query_exec("UPDATE torrents SET " . join(",", $updateset) . " WHERE id=$torrentid");
// Make sure $updateset is an array or an object implementing Countable
if (is_array($updateset) || $updateset instanceof Countable) {
$updatesCount = count($updateset);
if ($updatesCount > 0) {
$updatesString = join(",", $updateset);
SQL_Query_exec("UPDATE torrents SET $updatesString WHERE id=$torrentid");
}
} echo "<br /><br /><b>".T_("FILE_LIST").":</b> <img src='images/plus.gif' id='pic1' onclick='klappe_torrent(1)' alt='' /><div id='k1' style='display: none;'><table align='center' cellpadding='0' cellspacing='0' class='table_table' border='1' width='100%'><tr><th width='50' class='table_head'> ".T_("TYPE")."</th><th class='table_head' align='left'> ".T_("FILE")."</th><th width='50' class='table_head'> ".T_("SIZE")."</th></tr>";
$fres = SQL_Query_exec("SELECT * FROM `files` WHERE `torrent` = $id ORDER BY `path` ASC");
if (mysqli_num_rows($fres)) {
while ($frow = mysqli_fetch_assoc($fres)) {
$ext = pathinfo($frow['path'], PATHINFO_EXTENSION);
$filetype_icons = [
"mp3" => "/images/filetype-icons/mp3.png",
"iso" => "/images/filetype-icons/iso.png",
"mp4" => "/images/filetype-icons/mp4.png",
"png" => "/images/filetype-icons/png.png",
"jpg" => "/images/filetype-icons/jpg.png",
"mkv" => "/images/filetype-icons/mkv.png",
"rar" => "/images/filetype-icons/rar.png",
"avi" => "/images/filetype-icons/avi.png",
"nfo" => "/images/filetype-icons/nfo.png"
];
if(preg_match("/^r\d{2}$/", $ext)) {
$filetype_icon = "<img width=40 height=40 src='/images/filetype-icons/rar.png'>";
} elseif(isset($filetype_icons[$ext])) {
$filetype_icon = "<img width=40 height=40 src='" . $filetype_icons[$ext] . "'>";
} else {
$filetype_icon = "<img width=40 height=40 src='/images/filetype-icons/unknown.png'>";
}
echo "<tr><td class='table_col1'>".$filetype_icon."</td><td class='table_col1'>".htmlspecialchars($frow['path'])."</td><td class='table_col2'>".mksize($frow['filesize'])."</td></tr>";
} <?php
require_once("backend/functions.php");
dbconn();
$dir = "import";
//ini_set("upload_max_filesize",$max_torrent_size);
$files = array();
$dh = opendir("$dir/");
while (false !== ($file=readdir($dh))) {
if (preg_match("/\.torrent$/i", $file))
$files[] = $file;
}
closedir($dh);
// check access and rights
if ($CURUSER["edit_torrents"] != "yes")
show_error_msg(T_("ERROR"), T_("ACCESS_DENIED"), 1);
$announce_urls = explode(",", strtolower($site_config["announce_list"])); //generate announce_urls[] from config.php
if ($_POST["takeupload"] == "yes") {
set_time_limit(0);
require_once("backend/parse.php");
stdhead(T_("UPLOAD_COMPLETE"));
begin_frame(T_("UPLOAD_COMPLETE"));
echo "<center>";
//check form data
$catid = (int)$_POST["type"];
if (!is_valid_id($catid))
$message = T_("UPLOAD_NO_CAT");
if (empty($message)) {
$r = SQL_Query_exec("SELECT name, parent_cat FROM categories WHERE id=$catid");
$r = mysqli_fetch_row($r);
echo "<b>Category:</b> ".htmlspecialchars($r[1])." -> ".htmlspecialchars($r[0])."<br />";
for ($i=0;$i<count($files);$i++) {
$fname = $files[$i];
$descr = T_("UPLOAD_NO_DESC");
$langid = (int)$_POST["lang"];
preg_match('/^(.+)\.torrent$/si', $fname, $matches);
$shortfname = $torrent = $matches[1];
//parse torrent file
$torrent_dir = $site_config["torrent_dir"];
$TorrentInfo = array();
$TorrentInfo = ParseTorrent("$dir/$fname");
$announce = strtolower($TorrentInfo[0]);
$infohash = $TorrentInfo[1];
$creationdate = $TorrentInfo[2];
$internalname = $TorrentInfo[3];
$torrentsize = $TorrentInfo[4];
$filecount = $TorrentInfo[5];
$annlist = $TorrentInfo[6];
$comment = $TorrentInfo[7];
$message = "<br /><br /><hr /><br /><b>$internalname</b><br /><br />fname: ".htmlspecialchars($fname)."<br />message: ";
//check announce url is local or external
if (!in_array($announce, $announce_urls, 1))
$external='yes';
else
$external='no';
if (!$site_config["ALLOWEXTERNAL"] && $external == 'yes') {
$message .= T_("UPLOAD_NO_TRACKER_ANNOUNCE");
echo $message;
continue;
}
$name = $internalname;
$name = str_replace(".torrent","",$name);
$name = str_replace("_", " ", $name);
// Make torrent private
if ($external == "no") {
require_once("backend/BDecode.php");
require_once("backend/BEncode.php");
$dict = BDecode(file_get_contents("$torrent_dir/$fname"));
$dict["info"]["private"] = 1;
$fs = fopen("$torrent_dir/$fname", "w");
fwrite($fs, BEncode($dict));
fclose($fs);
$TorrentInfo = array();
$TorrentInfo = ParseTorrent("$torrent_dir/$fname");
$infohash = $TorrentInfo[1];
}
// End add make torrent private
//anonymous upload
$anonyupload = $_POST["anonycheck"];
if ($anonyupload == "yes")
$anon = "yes";
else
$anon = "no";
$ret = SQL_Query_exec("INSERT INTO torrents (filename, owner, name, descr, category, added, info_hash, size, numfiles, save_as, announce, external, torrentlang, anon, last_action) VALUES (".sqlesc($fname).", '".$CURUSER['id']."', ".sqlesc($name).", ".sqlesc($descr).", '".$catid."', '" . get_date_time() . "', '".$infohash."', '".$torrentsize."', '".$filecount."', ".sqlesc($fname).", '".$announce."', '".$external."', '".$langid."','$anon', '".get_date_time()."')");
$id = mysqli_insert_id($GLOBALS["DBconnector"]);
if (mysqli_errno($GLOBALS["DBconnector"]) == 1062) {
$message .= T_("UPLOAD_ALREADY_UPLOADED");
echo $message;
continue;
}
if($id == 0){
$message .= T_("UPLOAD_NO_ID");
echo $message;
continue;
}
copy("$dir/$files[$i]", "uploads/$id.torrent");
//EXTERNAL SCRAPE
if ($external=='yes' && $site_config['UPLOADSCRAPE']) {
$tracker = str_replace("/announce","/scrape",$announce);
$stats = torrent_scrape_url($tracker, $infohash);
$seeders = strip_tags($stats['seeds']);
$leechers = strip_tags($stats['peers']);
$downloaded = strip_tags($stats['downloaded']);
SQL_Query_exec("UPDATE torrents SET leechers='".$leechers."', seeders='".$seeders."',times_completed='".$downloaded."',last_action= '".get_date_time()."',visible='yes' WHERE id='".$id."'");
}
//END SCRAPE
write_log("Torrent $id ($name) was Uploaded by $CURUSER[username]");
$message .= "<br /><b>".T_("UPLOAD_OK")."</b><br /><a href='torrents-details.php?id=".$id."'>".T_("UPLOAD_VIEW_DL")."</a><br /><br />";
echo $message;
@unlink("$dir/$fname");
}
echo "</center>";
end_frame();
stdfoot();
die;
}else
show_error_msg(T_("UPLOAD_FAILED"), $message, 1);
}//takeupload
///////////////////// FORMAT PAGE ////////////////////////
stdhead(T_("UPLOAD"));
begin_frame(T_("UPLOAD"));
?>
<form name="upload" enctype="multipart/form-data" action="torrents-import.php" method="post">
<input type="hidden" name="takeupload" value="yes" />
<table border="0" cellspacing="0" cellpadding="6" align="center">
<tr><td align="right" valign="top"><b>File List:</b></td><td align="left"><?php
if (!count($files))
echo T_("NOTHING_TO_SHOW_FILES") ." $dir";
else{
foreach ($files as $f)
echo htmlspecialchars($f)."<br />";
echo "<br />Total files: ".count($files);
}?></td></tr>
<?php
$category = "<select name=\"type\">\n<option value=\"0\">" .T_("CHOOSE_ONE"). "</option>\n";
$cats = genrelist();
foreach ($cats as $row)
$category .= "<option value=\"" . $row["id"] . "\">" . htmlspecialchars($row["parent_cat"]) . ": " . htmlspecialchars($row["name"]) . "</option>\n";
$category .= "</select>\n";
print ("<tr><td align='right'>" .T_("CATEGORY"). ": </td><td align='left'>".$category."</td></tr>");
$language = "<select name=\"lang\">\n<option value=\"0\">Unknown/NA</option>\n";
$langs = langlist();
foreach ($langs as $row)
$language .= "<option value=\"" . $row["id"] . "\">" . htmlspecialchars($row["name"]) . "</option>\n";
$language .= "</select>\n";
print ("<tr><td align='right'>Language: </td><td align='left'>".$language."</td></tr>");
if ($site_config['ANONYMOUSUPLOAD']){ ?>
<tr><td align="right"><?php echo T_("UPLOAD_ANONY");?>: </td><td><?php printf("<input name='anonycheck' value='yes' type='radio' " . ($anonycheck ? " checked='checked'" : "") . " />Yes <input name='anonycheck' value='no' type='radio' " . (!$anonycheck ? " checked='checked'" : "") . " />No"); ?> <?php echo T_("UPLOAD_ANONY_MSG");?>
</td></tr>
<?php } ?>
<tr><td align="center" colspan="2"><input type="submit" value="<?php echo T_("UPLOAD")?>" /><br />
<i><?php echo T_("CLICK_ONCE_IMAGE");?></i></td></tr></table></form>
<?php
end_frame();
stdfoot();
?> print("<td class='ttable_col$x' nowrap='nowrap'>".(count($expandrows)?"<a href=\"javascript: klappe_torrent('t".$row['id']."')\"><img border=\"0\" src=\"".$site_config["SITEURL"]."/images/plus.gif\" id=\"pict".$row['id']."\" alt=\"Show/Hide\" class=\"showthecross\" /></a>":"")." <a href=\"torrents-details.php?id=$id&hit=1\" onMouseover=\"return overlib('<table class=ballooncolor border=1 width=100% class=ttable_headinner cellspacing=0 cellpadding=5 align=center><tr><td class=balloonheadercolor colspan=2 align=center>$smallname</td></tr><tr valign=top><td class=table_col1 align=center><img border=0 width=120 src=$balon></td><tr><td class=balloonheadercolor colspan=2 align=center>".T_("DESCRIPTION")."</td></tr><tr><td class=table_col1 colspan=2>" . CutName($des, $char5) . "</td></tr></table>', CENTER, HEIGHT, 150, WIDTH, 300)\"; onMouseout=\"return nd()\">".$dispname."</a></td>");
break; $subact = $_POST["subact"]; if ($action == "polls" && $do == "save") {
$subact = filter_input(INPUT_POST, 'subact', FILTER_SANITIZE_STRING);
$pollid = (int)$_POST["pollid"];
$question = filter_input(INPUT_POST, 'question', FILTER_SANITIZE_STRING);
$option0 = filter_input(INPUT_POST, 'option0', FILTER_SANITIZE_STRING);
$option1 = filter_input(INPUT_POST, 'option1', FILTER_SANITIZE_STRING);
$option2 = filter_input(INPUT_POST, 'option2', FILTER_SANITIZE_STRING);
$option3 = filter_input(INPUT_POST, 'option3', FILTER_SANITIZE_STRING);
$option4 = filter_input(INPUT_POST, 'option4', FILTER_SANITIZE_STRING);
$option5 = filter_input(INPUT_POST, 'option5', FILTER_SANITIZE_STRING);
$option6 = filter_input(INPUT_POST, 'option6', FILTER_SANITIZE_STRING);
$option7 = filter_input(INPUT_POST, 'option7', FILTER_SANITIZE_STRING);
$option8 = filter_input(INPUT_POST, 'option8', FILTER_SANITIZE_STRING);
$option9 = filter_input(INPUT_POST, 'option9', FILTER_SANITIZE_STRING);
$option10 = filter_input(INPUT_POST, 'option10', FILTER_SANITIZE_STRING);
$option11 = filter_input(INPUT_POST, 'option11', FILTER_SANITIZE_STRING);
$option12 = filter_input(INPUT_POST, 'option12', FILTER_SANITIZE_STRING);
$option13 = filter_input(INPUT_POST, 'option13', FILTER_SANITIZE_STRING);
$option14 = filter_input(INPUT_POST, 'option14', FILTER_SANITIZE_STRING);
$option15 = filter_input(INPUT_POST, 'option15', FILTER_SANITIZE_STRING);
$option16 = filter_input(INPUT_POST, 'option16', FILTER_SANITIZE_STRING);
$option17 = filter_input(INPUT_POST, 'option17', FILTER_SANITIZE_STRING);
$option18 = filter_input(INPUT_POST, 'option18', FILTER_SANITIZE_STRING);
$option19 = filter_input(INPUT_POST, 'option19', FILTER_SANITIZE_STRING);
$sort = $_POST["sort"]; SHOW VARIABLES LIKE 'sql_mode'; should look like this, if not, change it $ret = SQL_Query_exec("INSERT INTO peers (connectable, torrent, peer_id, ip, passkey, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, client) VALUES ('$connectable', $torrentid, '" . sqlesc($peer_id) . "', '" . sqlesc($ip) . "', '" . sqlesc($passkey) . "', $port, $uploaded, $downloaded, $left, '".get_date_time()."', '".get_date_time()."', '$seeder', '$userid', '" . sqlesc($agent) . "')");function sqlesc($x) {
return mysqli_real_escape_string($GLOBALS["DBconnector"], $x);
}$maxlength = 25;
if (strlen($agent) > $maxlength) {
$agent = substr($agent, 0, $maxlength);
} if (count($updateset))
SQL_Query_exec("UPDATE torrents SET " . join(",", $updateset) . " WHERE id=$torrentid"); if (is_countable($updateset) && count($updateset))
SQL_Query_exec("UPDATE torrents SET " . join(",", $updateset) . " WHERE id=$torrentid");if (is_array($updateset) || $updateset instanceof Countable) {
$updatesCount = count($updateset);
if ($updatesCount > 0) {
$updatesString = join(",", $updateset);
SQL_Query_exec("UPDATE torrents SET $updatesString WHERE id=$torrentid");
}
}