PHP Code:
<?php
function show_upload_errors()
{
global $UploadErrors;
global $lang;
global $BASEURL;
global $pic_base_url;
if (0 < count($UploadErrors)) {
$Errors = '';
foreach ($UploadErrors as $Error) {
$Errors .= '<img src="'.$pic_base_url.'error.gif" border="0" alt="" title="" /> '.$Error.'<br />';
}
echo show_notice($Errors, 1, $lang->upload['error']);
unset($Errors);
}
}
define('TU_VERSION', '3.0.7 by xam');
define('THIS_SCRIPT', 'upload.php');
require('./global.php');
if (!isset($CURUSER)) {
print_no_permission();
}
//@ini_set('upload_max_filesize', 1000 < $max_torrent_size ? $max_torrent_size : 10485760);
@ini_set('upload_max_filesize', 1000 < $max_torrent_size ? $max_torrent_size : 60485760);
@ini_set('memory_limit', '20000M');
$lang->load('upload');
$TSSEConfig->TSLoadConfig('ANNOUNCE');
require_once(INC_PATH.'/editor.php');
$ModerateTorrent = $usergroups['canupload'] == 'moderate' ? true : false;
$CanUploadExternalTorrent = $usergroups['canexternal'] == 'yes' && $externalscrape == 'yes' ? true : false;
$AnnounceURL = trim($xbt_active == 'yes' ? $xbt_announce_url.'/'.$CURUSER['torrent_pass'].'/announce' : $announce_urls['0'] .' ?passkey=' . $CURUSER['torrent_pass']);
$postoptions = '';
$postoptionstitle = '';
$UploadErrors = array();
if (isset($_GET['id']) && is_valid_id($_GET['id'])) {
if ($EditTorrentID = intval(TS_Global('id'))) {
$Query = sql_query('SELECT * FROM torrents WHERE id = ' . sqlesc($EditTorrentID));
if (mysql_num_rows($Query)) {
$EditTorrent = mysql_fetch_assoc($Query);
if ($EditTorrent['owner'] != $CURUSER['id'] && !$is_mod) {
print_no_permission(true);
}
$name = $EditTorrent['name'];
$descr = $EditTorrent['descr'];
$IsExternalTorrent = $EditTorrent['ts_external'] == 'yes' && $CanUploadExternalTorrent ? true : false;
$category = intval($EditTorrent['category']);
$t_image_url = $EditTorrent['t_image'];
$t_link = $EditTorrent['t_link'];
if ($t_link && preg_match('@http:\\/\\/www.imdb.com\\/title\\/(.*)\\/@isU', $t_link, $result)) {
$t_link = $result['0'];
unset($result);
}
$offensive = $EditTorrent['offensive'];
$anonymous = $EditTorrent['anonymous'];
$free = $EditTorrent['free'];
$silver = $EditTorrent['silver'];
$doubleupload = $EditTorrent['doubleupload'];
$allowcomments = $EditTorrent['allowcomments'];
$sticky = $EditTorrent['sticky'];
$isrequest = $EditTorrent['isrequest'];
$isnuked = $EditTorrent['isnuked'];
$WhyNuked = $EditTorrent['WhyNuked'];
if ($use_torrent_details == 'yes') {
$query = sql_query('SELECT * FROM ts_torrents_details WHERE tid = ' . sqlesc($EditTorrentID));
if (mysql_num_rows($query)) {
$videot = explode('~', mysql_result($query, 0, 'video_info'));
$video['codec'] = isset($videot['0']) ? $videot['0'] : '';
$video['bitrate'] = isset($videot['1']) ? $videot['1'] : '';
$video['resulation'] = isset($videot['2']) ? $videot['2'] : '';
$video['length'] = isset($videot['3']) ? $videot['3'] : '';
$video['quality'] = isset($videot['4']) ? $videot['4'] : '';
$audiot = explode('~', mysql_result($query, 0, 'audio_info'));
$audio['codec'] = isset($audiot['0']) ? $audiot['0'] : '';
$audio['bitrate'] = isset($audiot['1']) ? $audiot['1'] : '';
$audio['frequency'] = isset($audiot['2']) ? $audiot['2'] : '';
$audio['language'] = isset($audiot['3']) ? $audiot['3'] : '';
}
}
} else {
print_no_permission();
}
} else {
print_no_permission();
}
}
if ($usergroups['canupload'] == 'no') {
print_no_permission(false, true, $lang->upload['uploaderform']);
}
$query = sql_query('SELECT userid FROM ts_u_perm WHERE userid = ' . sqlesc($CURUSER['id']) . ' AND canupload = \'0\'');
if (mysql_num_rows($query)) {
print_no_permission(false, true, $lang->upload['uploaderform']);
}
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
$name = TS_Global('subject');
$descr = TS_Global('message');
$torrentfile = $_FILES['torrentfile'];
$IsExternalTorrent = isset($_POST['IsExternalTorrent']) && $_POST['IsExternalTorrent'] == 'yes' && $CanUploadExternalTorrent ? true : false;
$nfofile = $_FILES['nfofile'];
$UseNFOasDescr = TS_Global('UseNFOasDescr');
$category = intval(TS_Global('category'));
$t_image_url = TS_Global('t_image_url');
$t_image_file = $_FILES['t_image_file'];
$t_link = TS_Global('t_link');
$isScene = TS_Global('isScene');
$offensive = TS_Global('offensive');
$anonymous = TS_Global('anonymous');
$free = TS_Global('free');
$silver = TS_Global('silver');
$doubleupload = TS_Global('doubleupload');
$allowcomments = TS_Global('allowcomments');
$sticky = TS_Global('sticky');
$isrequest = TS_Global('isrequest');
$isnuked = TS_Global('isnuked');
$WhyNuked = TS_Global('WhyNuked');
if ($use_torrent_details == 'yes') {
$audio = $_POST['audio'];
$video = $_POST['video'];
}
if (isset($nfofile['name']) && !empty($nfofile['name'])) {
if (get_extension($nfofile['name']) != 'nfo') {
$UploadErrors[] = $lang->upload['error10'];
}
if ($nfofile['size'] == '0') {
$UploadErrors[] = $lang->upload['error11'];
}
if ($nfofile['error'] != '0') {
$UploadErrors[] = $lang->upload['error6'] . ' {' . intval($nfofile['error']) . '}';
}
if (!is_file($nfofile['tmp_name'])) {
$UploadErrors[] = $lang->upload['error6'] . ' {' . intval($nfofile['error']) . '}';
}
if (count($UploadErrors) == 0) {
$NfoContents = file_get_contents($nfofile['tmp_name']);
}
}
if (empty($name) || strlen($name) < 5) {
if (isset($torrentfile['name']) && !empty($torrentfile['name'])) {
$name = str_replace('.torrent', '', $torrentfile['name']);
} else {
$UploadErrors[] = $lang->upload['error1'];
}
}
if (empty($descr) || strlen($descr) < 10) {
if ($UseNFOasDescr == 'yes' && isset($NfoContents) && !empty($NfoContents))
{
} else {
$UploadErrors[] = $lang->upload['error2'];
}
}
if (isset($torrentfile['name']) && !empty($torrentfile['name']) && !$IsExternalTorrent) {
$UpdateHash = true;
}
$torrentfile['name'] = $EditTorrent['filename'];
$torrentfile['type'] = 'application/x-bittorrent';
$torrentfile['size'] = $EditTorrent['size'];
$torrentfile['error'] = 0;
//$torrentfile['tmp_name'] = $torrent_dir . '/' . $EditTorrentID . '.torrent';
$torrentfile['tmp_name'] = $torrent_dir . '/' . $EditTorrentID . '.torrent';
if (isset($torrentfile['name']) && !empty($torrentfile['name'])) {
if (get_extension($torrentfile['name']) != 'torrent') {
$UploadErrors[] = $lang->upload['error3'];
}
if ($torrentfile['size'] == '0') {
$UploadErrors[] = $lang->upload['error5'];
}
if ($torrentfile['error'] != '0') {
$UploadErrors[] = $lang->upload['error6'] . ' {' . intval($torrentfile['error']) . '}';
}
if (!is_file($torrentfile['tmp_name'])) {
$UploadErrors[] = $lang->upload['error6'] . ' {' . intval($torrentfile['error']) . '}';
}
} else {
$UploadErrors[] = $lang->upload['error3'];
}
if (!$category) {
$UploadErrors[] = $lang->upload['error9'];
}
if (count($UploadErrors) == 0) {
require_once(INC_PATH . '/class_torrent.php');
if ($Data = file_get_contents($torrentfile['tmp_name'])) {
$Torrent = new Torrent();
if ($Torrent->load($Data)) {
$info_hash = $Torrent->getHash();
if ($privatetrackerpatch == 'yes' && $IsExternalTorrent && $Torrent->getWhatever('announce') == $AnnounceURL && $Torrent->getWhatever('announce-list') == null) {
$IsExternalTorrent = false;
}
if ($privatetrackerpatch == 'yes' && !$IsExternalTorrent) {
$Torrent->removeWhatever('announce-list');
$Torrent->removeWhatever('nodes');
if ($Torrent->getPrivate() != '1') {
$Torrent->setPrivate('1');
}
if ($Torrent->getWhatever('announce') != $AnnounceURL) {
$Torrent->setTrackers(array(
$AnnounceURL
));
}
}
if ($privatetrackerpatch != 'yes' && !$IsExternalTorrent && $Torrent->getWhatever('announce') != $AnnounceURL) {
$Torrent->addTracker($AnnounceURL);
}
if (strlen($Torrent->getPieces()) % 20 != 0) {
$UploadErrors[] = $lang->upload['error7'];
}
} else {
$UploadErrors[] = $lang->global['error'] . ': ' . htmlspecialchars_uni($Torrent->error);
}
} else {
$UploadErrors[] = $lang->upload['error7'];
}
}
if (count($UploadErrors) == 0) {
$Torrent->setComment($lang->upload['DefaultTorrentComment']);
$Torrent->setCreatedBy(sprintf($lang->upload['CreatedBy'], $anonymous == 'yes' ? '' : $CURUSER['username']) . ' [' . $SITENAME . ']');
$Torrent->setSource($BASEURL);
$Torrent->setCreationDate(TIMENOW);
$check_info_hash = $Torrent->getHash();
if ($info_hash != $check_info_hash) {
$info_hash = $check_info_hash;
unset($check_info_hash);
$UpdateHash = true;
$Info_hash_changed = true;
}
$numfiles = 0;
$size = 0;
$IncludedFiles = $Torrent->getFiles();
foreach ($IncludedFiles as $File) {
++$numfiles;
$size += $File->length;
}
$filename = str_replace('.torrent', '', $torrentfile['name']);
$filename = MakeFriendlyText($filename);
$filename = $filename . '.torrent';
$UpdateSet = array();
if (isset($UpdateHash) || !isset($EditTorrent)) {
$UpdateSet[] = 'info_hash = ' . sqlesc($info_hash);
}
$UpdateSet[] = 'name = ' . sqlesc($name);
$UpdateSet[] = 'filename = ' . sqlesc($filename);
$UpdateSet[] = 'category = ' . sqlesc($category);
$UpdateSet[] = 'size = ' . sqlesc($size);
$UpdateSet[] = 'numfiles = ' . sqlesc($numfiles);
if ($descr) {
$UpdateSet[] = 'descr = ' . sqlesc($descr);
}
if (!isset($EditTorrent)) {
$UpdateSet[] = 'added = NOW()';
$UpdateSet[] = 'ctime = UNIX_TIMESTAMP()';
$UpdateSet[] = 'owner = ' . sqlesc($CURUSER['id']);
} else {
$UpdateSet[] = 'mtime = UNIX_TIMESTAMP()';
}
if ($is_mod) {
if ($free == 'yes') {
$UpdateSet[] = 'free = \'yes\'';
$UpdateSet[] = 'silver = \'no\'';
$UpdateSet[] = 'download_multiplier = \'0\'';
} else if ($silver == 'yes') {
$UpdateSet[] = 'silver = \'yes\'';
$UpdateSet[] = 'free = \'no\'';
$UpdateSet[] = 'download_multiplier = \'0.5\'';
} else {
$UpdateSet[] = 'silver = \'no\'';
$UpdateSet[] = 'free = \'no\'';
$UpdateSet[] = 'download_multiplier = \'1\'';
}
if ($doubleupload == 'yes') {
$UpdateSet[] = 'doubleupload = \'yes\'';
$UpdateSet[] = 'upload_multiplier = \'2\'';
} else {
$UpdateSet[] = 'doubleupload = \'no\'';
$UpdateSet[] = 'upload_multiplier = \'1\'';
}
$UpdateSet[] = '`flags` = \'' . ($free == 'yes' || $free != 'yes' && $silver == 'yes' || $doubleupload == 'yes' ? 2 : 0) . '\'';
if ($allowcomments == 'no') {
$UpdateSet[] = 'allowcomments = \'no\'';
} else {
$UpdateSet[] = 'allowcomments = \'yes\'';
}
if ($sticky == 'yes') {
$UpdateSet[] = 'sticky = \'yes\'';
} else {
$UpdateSet[] = 'sticky = \'no\'';
}
if ($isnuked == 'yes') {
$UpdateSet[] = 'WhyNuked = ' . sqlesc($WhyNuked);
$UpdateSet[] = 'isnuked = \'yes\'';
} else {
$UpdateSet[] = 'WhyNuked = \'\'';
$UpdateSet[] = 'isnuked = \'no\'';
}
}
if ($isrequest == 'yes') {
$UpdateSet[] = 'isrequest = \'yes\'';
} else {
$UpdateSet[] = 'isrequest = \'no\'';
}
if ($anonymous == 'yes') {
$UpdateSet[] = 'anonymous = \'yes\'';
} else {
$UpdateSet[] = 'anonymous = \'no\'';
}
if ($offensive == 'yes') {
$UpdateSet[] = 'offensive = \'yes\'';
} else {
$UpdateSet[] = 'offensive = \'no\'';
}
if ($IsExternalTorrent) {
$UpdateSet[] = 'ts_external = \'yes\'';
$UpdateSet[] = 'ts_external_url = ' . sqlesc($Torrent->getWhatever('announce'));
$UpdateSet[] = 'visible = \'yes\'';
} else {
$UpdateSet[] = 'ts_external = \'no\'';
$UpdateSet[] = 'ts_external_url = \'\'';
if (!isset($EditTorrent) && $xbt_active != 'yes') {
$UpdateSet[] = 'visible = \'no\'';
}
}
if ($isScene && $isScene != 0 - 1) {
$UpdateSet[] = 'isScene = ' . sqlesc(intval(TS_MTStoUTS($isScene)));
} else if ($isScene == 0 - 1) {
$UpdateSet[] = 'isScene = \'0\'';
} else if (isset($_POST['autopretime']) && $_POST['autopretime'] == 'yes') {
$__PreTime = '';
$__Torrent = $name;
require('./pretime.php');
if ($__PreTime) {
$UpdateSet[] = 'isScene = ' . sqlesc(intval(TS_MTStoUTS($__PreTime)));
}
}
if (!isset($EditTorrentID)) {
if ($ModerateTorrent) {
$UpdateSet[] = 'moderate = \'1\'';
} else {
$UpdateSet[] = 'moderate = \'0\'';
}
}
if (empty($t_link)) {
$UpdateSet[] = 't_link = \'\'';
} else {
if (substr($t_link, 0 - 1, 1) != '/') {
$t_link = $t_link . '/';
}
if (preg_match('@^http:\\/\\/www.imdb.com\\/title\\/(.*)\\/\$@isU', $t_link, $result) && $result['0']) {
$t_link = $result['0'];
include_once(INC_PATH . '/ts_imdb.php');
$UpdateSet[] = 't_link = ' . sqlesc($t_link);
unset($result);
}
}
if (empty($t_image_url)) {
$UpdateSet[] = 't_image = \'\'';
}
if (!sql_query((isset($EditTorrent) ? 'UPDATE' : 'INSERT INTO') . ' torrents SET ' . implode(', ', $UpdateSet) . (isset($EditTorrent) ? ' WHERE id = ' . sqlesc($EditTorrentID) : ''))) {
stderr($lang->global['error'], $lang->upload['error13'] . ' {' . htmlspecialchars_uni(mysql_error()) . '}');
}
if (isset($EditTorrent)) {
$NewTID = $EditTorrentID;
if (is_file($torrent_dir . '/' . $NewTID . '.torrent')) {
@unlink($torrent_dir . '/' . $NewTID . '.torrent');
}
} else {
$NewTID = mysql_insert_id();
}
if (!empty($t_image_url)) {
$t_image_url = fix_url($t_image_url);
$AllowedFileTypes = array(
'jpg',
'gif',
'png'
);
$ImageExt = get_extension($t_image_url);
if (in_array($ImageExt, $AllowedFileTypes, true)) {
$AllowedMimeTypes = array(
'image/jpeg',
'image/gif',
'image/png'
);
$ImageDetails = getimagesize($t_image_url);
if ($ImageDetails && in_array($ImageDetails['mime'], $AllowedMimeTypes, true)) {
include_once(INC_PATH . '/functions_ts_remote_connect.php');
if ($ImageContents = TS_Fetch_Data($t_image_url, false)) {
$NewImageURL = $torrent_dir . '/images/' . $NewTID . '.' . $ImageExt;
if (file_exists($NewImageURL)) {
@unlink($NewImageURL);
}
if (file_put_contents($NewImageURL, $ImageContents)) {
$COVERIMAGEUPDATED = true;
sql_query('UPDATE torrents SET t_image = ' . sqlesc($BASEURL . '/' . $NewImageURL) . ' WHERE id = '. sqlesc($NewTID));
}
}
}
}
}
if (!empty($t_image_file) && 0 < $t_image_file['size'] && $t_image_file['error'] === 0 && $t_image_file['tmp_name'] && $t_image_file['name']) {
$t_image_url = fix_url($t_image_file['name']);
$AllowedFileTypes = array(
'jpg',
'gif',
'png'
);
$ImageExt = get_extension($t_image_url);
if (in_array($ImageExt, $AllowedFileTypes, true)) {
$AllowedMimeTypes = array(
'image/jpeg',
'image/gif',
'image/png'
);
$ImageDetails = getimagesize($t_image_file['tmp_name']);
if ($ImageDetails && in_array($ImageDetails['mime'], $AllowedMimeTypes, true) && ($ImageContents = file_get_contents($t_image_file['tmp_name']))) {
$NewImageURL = $torrent_dir . '/images/' . $NewTID . '.' . $ImageExt;
if (file_exists($NewImageURL)) {
@unlink($NewImageURL);
}
if (file_put_contents($NewImageURL, $ImageContents)) {
$COVERIMAGEUPDATED = true;
sql_query('UPDATE torrents SET t_image = ' . sqlesc($BASEURL . '/' . $NewImageURL) . ' WHERE id = ' . sqlesc($NewTID));
}
}
}
}
if (!isset($COVERIMAGEUPDATED) && isset($cover_photo_name)) {
sql_query('UPDATE torrents SET t_image = ' . sqlesc($BASEURL . '/' . $cover_photo_name) . ' WHERE id = '. sqlesc($NewTID));
}
if ($use_torrent_details == 'yes') {
sql_query('DELETE FROM ts_torrents_details WHERE tid = ' . sqlesc($NewTID));
foreach ($video as $vt) {
if (!empty($vt)) {
$InsertTdetails = true;
}
}
foreach ($audio as $vt) {
if (!empty($vt)) {
$InsertTdetails = true;
}
}
if (isset($InsertTdetails)) {
$video_info = implode('~', $video);
$audio_info = implode('~', $audio);
sql_query('INSERT INTO ts_torrents_details VALUES (NULL, ' . sqlesc($NewTID) . ', ' . sqlesc($video_info) . ', ' . sqlesc($audio_info) . ')');
}
}
if (isset($EditTorrent)) {
write_log(sprintf($lang->upload['editedtorrent'], $name, $CURUSER['username']));
} else {
write_log(sprintf($lang->upload['newtorrent'], $name, $CURUSER['username']));
}
$TorrentContents = $Torrent->bencode();
if ($TorrentContents && file_put_contents($torrent_dir . '/' . $NewTID . '.torrent', $TorrentContents)) {
if ($IsExternalTorrent) {
$externaltorrent = $torrent_dir . '/' . $NewTID . '.torrent';
$id = $NewTID;
include_once(INC_PATH . '/ts_external_scrape/ts_external.php');
}
if (isset($NfoContents) && !empty($NfoContents)) {
if ($UseNFOasDescr == 'yes') {
$NewDescr = $BASEURL . '/viewnfo.php?id=' . $NewTID;
sql_query('UPDATE torrents SET descr = ' . sqlesc($NewDescr) . ' WHERE id = ' . sqlesc($NewTID));
}
sql_query('REPLACE INTO ts_nfo (id, nfo) VALUES (' . $NewTID . ', ' . sqlesc($NfoContents) . ')');
}
if ($ModerateTorrent && !isset($EditTorrentID)) {
$msgtext = sprintf($lang->upload['modmsgss'], $name, $CURUSER['username'], '[URL]' . $BASEURL . '/details.php?id=' . $NewTID . '[/URL]');
$message = sqlesc($msgtext);
$subject = sqlesc($lang->upload['modmsgs']);
if (!sql_query('INSERT INTO staffmessages (sender, added, msg, subject) VALUES(0, NOW(), '.$message.', '.$subject.')')) {
sqlerr(__FILE__, 705);
}
stderr($lang->upload['title'], $lang->upload['mulmsg']);
} else if (!isset($EditTorrent)) {
$TSSEConfig->TSLoadConfig('KPS');
KPS("+", $kpsupload, $CURUSER['id']);
$res = sql_query('SELECT name FROM categories WHERE id = ' . sqlesc($category));
$cat = mysql_result($res, 0, 'name');
$res = sql_query('SELECT u.email FROM users u LEFT JOIN usergroups g ON (u.usergroup=g.gid) WHERE u.enabled=\'yes\' AND u.status=\'confirmed\' AND u.notifs LIKE \'%[cat'.$category.']%\' AND u.notifs LIKE \'%[email]%\' AND u.notifs != \'\' AND g.isvipgroup=\'yes\' AND g.canemailnotify=\'yes\'');
$size = mksize($size);
$body = sprintf($lang->upload['emailbody'], $name, $size, $cat, $anonymous == 'yes' ? 'N/A' : $CURUSER['username'], $descr, $BASEURL, $NewTID, $SITENAME);
$to = '';
$nmax = 100;
$nthis = $ntotal = 0;
$total = mysql_num_rows($res);
while (0 < $total && ($arr = mysql_fetch_row($res))) {
if ($nthis == 0) {
$to = $arr[0];
} else {
$to .= ',' . $arr[0];
}
++$nthis;
++$ntotal;
if ($nthis == $nmax || $ntotal == $total) {
$sm = sent_mail($to, sprintf($lang->upload['emailsubject'], $SITENAME, $name), $body, 'ts_upload_torrent', false);
$nthis = 0;
}
}
$TSSEConfig->TSLoadConfig('PJIRC');
if ($ircbot == 'yes' && ($connect = @fsockopen($botip, $botport, $errno, $errstr))) {
$botmessage = chr(3) . '9' . chr(2) . ' '.$SITENAME.'' . chr(2) . ' -' . chr(3) . '10 New Torrent: (' . chr(3) . '13 '.$name.'' . chr(3) . '10 ) Size: (' . chr(3) . '13 ' . $size . chr(3) . '10 ) Category: (' . chr(3) . '13 ' . $cat . chr(3) . '10 ) Uploader: (' . chr(3) . '13 ' . ($anonymous == 'yes' ? 'N/A' : $CURUSER['username']) . chr(3) . '10 ) Link: (' . chr(3) . '13 '.$BASEURL.'/details.php?id='.$NewTID.'' . chr(3) . '10 )';
@fwrite($connect, $botmessage);
@fclose($connect);
}
$TSSEConfig->TSLoadConfig('SHOUTBOX');
if ($tsshoutbot == 'yes' && TS_Match($tsshoutboxoptions, 'upload')) {
$seo_link = ts_seo($NewTID, $name, 's');
$shoutbOT = sprintf($lang->upload['shoutbOT'], $seo_link, $name, $anonymous == 'yes' ? 'N/A' : $CURUSER['username']);
require(INC_PATH . '/functions_ajax_chatbot.php');
TSAjaxShoutBOT($shoutbOT);
}
if (file_exists(TSDIR . '/' . $cache . '/latesttorrents.html')) {
@unlink(TSDIR . '/' . $cache . '/latesttorrents.html');
}
}
if (isset($Info_hash_changed)) {
stdhead($lang->upload['title']);
echo show_notice(sprintf($lang->upload['done'], 'download.php?id=' . $NewTID, 'details.php?id=' . $NewTID), false, $lang->upload['title']);
stdfoot();
exit();
} else {
redirect('details.php?id=' . $NewTID);
exit();
}
} else {
$UploadErrors[] = $lang->upload['error8'];
}
}
}
require(INC_PATH . '/functions_category.php');
$postoptionstitle = array(
3 => $lang->upload['category'],
4 => $lang->upload['cover'],
5 => $lang->upload['t_link'],
6 => $lang->upload['isScene1'],
7 => $lang->upload['offensive1'],
8 => $lang->upload['anonymous1'],
9 => $lang->upload['isrequest1']
);
$postoptions = array(
3 => ts_category_list('category', isset($category) ? $category : ''),
4 => '<input type="radio" name="nothingtopost" value="1" onclick="ChangeBox(this.value);" checked="checked" /> ' . $lang->upload['cover1'] . '<div style="display: inline;" id="nothingtopost1"><br /><input type="text" name="t_image_url" id="specialboxg" size="70" value="' . (isset($t_image_url) ? htmlspecialchars_uni($t_image_url) : '') . '" /></div><br /><input type="radio" name="nothingtopost" value="2" onclick="ChangeBox(this.value);" /> ' . $lang->upload['cover2'] . '<div style="display: none;" id="nothingtopost2"><br /><input type="file" name="t_image_file" id="specialboxg" size="70" /></div>',
5 => '<input type="text" name="t_link" id="specialboxg" size="70" value="' . (isset($t_link) ? htmlspecialchars_uni($t_link) : '') . '" /> ' . $lang->upload['t_link2'],
6 => '<input type="text" name="isScene" id="isScene" value="' . (isset($isScene) ? htmlspecialchars_uni($isScene) : '') . '" size="20" /> ' . $lang->upload['isScene2'] . '<br /><input type="checkbox" name="autopretime" id="autopretime" value="yes"' . (isset($_POST['autopretime']) && $_POST['autopretime'] == 'yes' ? ' checked="checked"' : '') . ' onclick="EnableDisableField(\'isScene\');" /> ' . $lang->upload['pretime'],
7 => '<input type="checkbox" name="offensive" value="yes"' . (isset($offensive) && $offensive == 'yes' ? ' checked="checked"' : '') . ' class="inlineimg" /> ' . $lang->upload['offensive2'],
8 => '<input type="checkbox" name="anonymous" value="yes"' . (isset($anonymous) && $anonymous == 'yes' || (TS_Match($CURUSER['options'], 'I3') || TS_Match($CURUSER['options'], 'I4')) ? ' checked="checked"' : '') . ' class="inlineimg" /> ' . $lang->upload['anonymous2'],
9 => '<input type="checkbox" name="isrequest" value="yes"' . (isset($isrequest) && $isrequest == 'yes' ? ' checked="checked"' : '') . ' class="inlineimg" /> ' . $lang->upload['isrequest2']
);
if ($is_mod) {
$postoptionstitle[] = '<fieldset><legend>' . $lang->upload['moptions'] . '</legend>';
$postoptions[] = '<table width="100%" cellpadding="4" cellspacing="0" border="0"><tr><td class="none"><b>'.$lang->upload['free1'].'</b><br /><input type="checkbox" name="free" value="yes"'.(isset($free) && $free == 'yes' ? ' checked="checked"' : '') . ' class="inlineimg" /> '.$lang->upload['free2'].'</td><td class="none"><b>'.$lang->upload['silver1'].'</b><br /><input type="checkbox" name="silver" value="yes"'.(isset($silver) && $silver == 'yes' ? ' checked="checked"' : '') . ' class="inlineimg" />'.$lang->upload['silver2'].'</td></tr><tr><td class="none"><b>'.$lang->upload['doubleupload1'].'</b><br /><input type="checkbox" name="doubleupload" value="yes"'.(isset($doubleupload) && $doubleupload == 'yes' ? ' checked="checked"' : '') . ' class="inlineimg" />'.$lang->upload['doubleupload2'].'</td><td class="none"><b>'.$lang->upload['allowcomments1'].'</b><br /><input type="checkbox" name="allowcomments" value="no"' . (isset($allowcomments) && $allowcomments == 'no' ? ' checked="checked"' : '') . ' class="inlineimg" /> ' . $lang->upload['allowcomments2'] . '</td></tr><tr><td class="none"><b>' . $lang->upload['sticky1'] . '</b><br /><input type="checkbox" name="sticky" value="yes"' . (isset($sticky) && $sticky == 'yes' ? ' checked="checked"' : '') . ' class="inlineimg" /> ' . $lang->upload['sticky2'] . '</td><td class="none"><b>'.$lang->upload['nuked1'].'</b><br /><input type="checkbox" name="isnuked" value="yes"' . (isset($isnuked) && $isnuked == 'yes' ? ' checked="checked"' : '') . ' class="inlineimg" onclick="ShowHideField(\'nukereason\');" /> ' . $lang->upload['nuked2'] . '<div style="display:' . (isset($isnuked) && $isnuked == 'yes' ? 'inline' : 'none') . ';" id="nukereason"><br /><b>' . $lang->upload['nreason'] . '</b> <input type="text" name="WhyNuked" value="' . (isset($WhyNuked) ? htmlspecialchars_uni($WhyNuked) : '') . '" size="40" /></div></td></tr></table></fieldset>';
}
if ($use_torrent_details == 'yes') {
$postoptionstitle[] = '<fieldset><legend>' . $lang->upload['tinfo'] . '</legend>';
$postoptions[] = '<table width="100%" cellpadding="4" cellspacing="0" border="0"><tr><td class="none"><table width="100%" cellpadding="4" cellspacing="0" border="0"><tr><td class="thead" colspan="2">' . $lang->upload['video'] . '</td></tr><tr><td>' . $lang->upload['codec'] . '</td><td><input type="text" name="video[codec]" size="20" value="' . (isset($video) && $video['codec'] ? htmlspecialchars_uni($video['codec']) : '') . '" /></td></tr><tr><td>' . $lang->upload['bitrate'] . '</td><td><input type="text" name="video[bitrate]" size="20" value="' . (isset($video) && $video['bitrate'] ? htmlspecialchars_uni($video['bitrate']) : '') . '" /></td></tr><tr><td>' . $lang->upload['resulation'] . '</td><td><input type="text" name="video[resulation]" size="20" value="' . (isset($video) && $video['resulation'] ? htmlspecialchars_uni($video['resulation']) : '') . '" /></td></tr><tr><td>' . $lang->upload['length'] . '</td><td><input type="text" name="video[length]" size="20" value="' . (isset($video) && $video['length'] ? htmlspecialchars_uni($video['length']) : '') . '" /></td></tr><tr><td>' . $lang->upload['quality'] . '</td><td><input type="text" name="video[quality]" size="20" value="' . (isset($video) && $video['quality'] ? htmlspecialchars_uni($video['quality']) : '') . '" /></td></tr></table></td><td class="none"><table width="100%" cellpadding="4" cellspacing="0" border="0"><tr><td class="thead" colspan="2">' . $lang->upload['audio'] . '</td></tr><tr><td>' . $lang->upload['codec'] . '</td><td><input type="text" name="audio[codec]" size="20" value="' . (isset($audio) && $audio['codec'] ? htmlspecialchars_uni($audio['codec']) : '') . '" /></td></tr><tr><td>' . $lang->upload['bitrate'] . '</td><td><input type="text" name="audio[bitrate]" size="20" value="' . (isset($audio) && $audio['bitrate'] ? htmlspecialchars_uni($audio['bitrate']) : '') . '" /></td></tr><tr><td>' . $lang->upload['frequency'] . '</td><td><input type="text" name="audio[frequency]" size="20" value="' . (isset($audio) && $audio['frequency'] ? htmlspecialchars_uni($audio['frequency']) : '') . '" /></td></tr><tr><td>' . $lang->upload['language'] . '</td><td><input type="text" name="audio[language]" size="20" value="' . (isset($audio) && $audio['language'] ? htmlspecialchars_uni($audio['language']) : '') . '" /></td></tr><tr><td colspan="2"><i>' . $lang->upload['tinfohelp'] . '</i></td></tr></table></td></tr></table></fieldset>';
}
$str = '';
if ($search_before_upload == 'yes') {
define('SUBJECT_EXTRA', ' onKeyDown="SearchBeforeUpload(this);" onKeyUp="SearchBeforeUpload(this);"');
$str .= '<script type="text/javascript" src="' . $BASEURL . '/scripts/quick_searchbu.js?v=' . O_SCRIPT_VERSION .'"></script><script type="text/javascript">function SearchBeforeUpload(Whatever){var subject = Whatever.value;var subjectlength = subject.length;var defaultContent = \'<img src="' . $BASEURL . '/include/templates/' . ts_template() .'/images/loading.gif" border="0" alt="' . $lang->global['pleasewait'] .'" title="' . $lang->global['pleasewait'] . '" class="inlineimg" /> ' . $lang->upload['sbu_wait'] . '\';if (subjectlength > 2){TSGetID("search_before_upload").style.display = "inline";get(subject);}else{TSGetID("search_before_upload").style.display = "none";TSGetID("search_before_upload_results").innerHTML = defaultContent;}}function EnableDisableField(fName){if(TSGetID(fName).disabled){TSGetID(fName).disabled = "";}else{TSGetID(fName).value = "";TSGetID(fName).disabled = "disabled";}}function ShowHideField(fName){if(TSGetID(fName).style.display == "inline"){TSGetID(fName).style.display = "none";}else{TSGetID(fName).style.display = "inline";}}</script><div id="search_before_upload" style="display: none;"><table width="100%" align="center" border="0" cellpadding="5" cellspacing="0"><tr><td class="thead">'.ts_collapse('sbu') .'' . $lang->upload['sbu'] . '</td></tr>' . ts_collapse('sbu', 2) . '<tr><td><div id="search_before_upload_results"></div></td></tr></table><br /></div>';
}
$str .= '<div id="ts_uploading_progress"></div><div id="ts_upload_form"><form method="post" action="' . $_SERVER['SCRIPT_NAME'] . (isset($EditTorrent) ? '?id=' . $EditTorrentID : '') . '" name="ts_upload_torrent" enctype="multipart/form-data" onsubmit="return ProcessUpload();">';
$FirstTabs = array(
$lang->upload['torrentfile'] => '<input type="file" name="torrentfile" id="torrentfile" onchange="checkFileName(this.value);" />'.($CanUploadExternalTorrent ? ' <input type="checkbox" name="IsExternalTorrent" value="yes"' . (isset($IsExternalTorrent) && $IsExternalTorrent == true ? ' checked="checked"' : '') . ' /> ' . $lang->upload['isexternal'] : ''),
$lang->upload['nfofile'] => '<input type="file" name="nfofile" id="nfofile" onchange="checknfoFileName(this.value);" /> <input type="checkbox" name="UseNFOasDescr" value="yes"' . (isset($UseNFOasDescr) && $UseNFOasDescr == 'yes' ? ' checked="checked"' : '') . ' onclick="enableDisableTA(this.checked);" /> ' . $lang->upload['UseNFOasDescr'],
$lang->upload['tname'] => '<input type="text" name="subject" id="subject" style="width: 650px" value="' . (isset($name) ? htmlspecialchars_uni($name) : '') . '" tabindex="1"' . (defined('SUBJECT_EXTRA') ? SUBJECT_EXTRA : '') . ' autocomplete="off" />'
);
$str .= insert_editor(false, '', isset($descr) ? $descr : '', $lang->upload['title'], sprintf($lang->upload['title2'], $AnnounceURL), $postoptionstitle, $postoptions, false, '', isset($EditTorrent) ? $lang->upload['savechanges'] : $lang->upload['title'], '', '', $FirstTabs);
$str .= '</form></div>
<script type="text/javascript">
function file_get_ext(filename)
{
return typeof filename != "undefined" ? filename.substring(filename.lastIndexOf(".")+1, filename.length).toLowerCase() : false;
}
function checkFileName(path)
{
var ext = file_get_ext(path);
var fullpath = path;
var newpath = fullpath.substring(0, fullpath.length-8);
TSGetID("subject").value = newpath;
if (!ext || ext != "torrent")
{
alert("'.strip_tags($lang->upload['error3']).'");
}
}
function checknfoFileName(path)
{
var ext = file_get_ext(path);
if (!ext || ext != "nfo")
{
alert("'.strip_tags( $lang->upload['error10'] ).'");
}
}
function enableDisableTA(cStatus)
{
if (cStatus == true)
{
TSGetID("message_new").disabled = "disabled";
TSGetID("message_old").disabled = "disabled";
TSGetID("message_new").value = "";
TSGetID("message_old").value = "";
}
else
{
TSGetID("message_new").disabled = "";
TSGetID("message_old").disabled = "";
}
}
function ProcessUpload()
{
TSGetID(\'ts_uploading_progress\').innerHTML = \'<table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td class="thead">'.$lang->global['pleasewait'].'</td></tr><tr><td><img src="include/templates/'.ts_template( ).'/images/loading.gif" border="0" alt="" title="" class="inlineimg" /> '.trim( $lang->upload['uploading'] ).'</td></tr></table>\';
TSGetID(\'ts_upload_form\').style.display = \'none\';
return true;
}
function ChangeBox(BoxValue)
{
TSGetID("nothingtopost1").style.display = "none";
TSGetID("nothingtopost2").style.display = "none";
TSGetID("nothingtopost"+BoxValue).style.display = "inline";
}
</script>';
if (isset($upload_page_notice) && !empty($upload_page_notice)) {
$str = show_notice($upload_page_notice) . $str;
}
stdhead($lang->upload['title']);
show_upload_errors();
echo $str;
stdfoot();
?>