bdecode($torrent); $size = 0; $hash = sha1($bencode->bencode($torrent["info"])); if(isset($torrent['info']['files']) && count($torrent['info']['files'])) { foreach($torrent['info']['files'] as $file) { $size += $file['length']; } } else { $size = $torrent['info']['length']; } $name = trim(strip_tags($_POST['filename'])); $tracker = strip_tags($torrent['announce']); $tracker = str_replace('announce', 'scrape', $tracker); $tracker = str_replace('HtTp://', 'http://', $tracker); $tracker = strip_tags(str_replace('announce', 'scrape', $tracker)); $subcat = strip_tags($_POST['type']); $registration = strip_tags($_POST['reg']); $date = date('YmdHis'); $maincat = mysql_query("SELECT catid FROM categories WHERE subid = '$subcat' LIMIT 1"); $maincat = mysql_fetch_row($maincat); $maincat = $maincat[0]; if($filename == '') { echo 'Filename empty'; @unlink($filename); die; } if($subcat == '') { echo 'Category empty'; @unlink($filename); die; } if($registration == '') { echo 'Tracker registration empty'; @unlink($filename); die; } if($tracker == '') { echo 'The tracker does not work'; @unlink($filename); die; } $result= mysql_query ("SELECT * FROM torrents WHERE hash = '$hash'"); if (mysql_num_rows($result) == 1) { echo 'This torrent is already uploaded'; @unlink($filename); die; } $tracker = str_replace('announce', 'scrape', $tracker) . '?info_hash='; for($i=0;$i<40;$i=$i+2) { $tracker .= '%'.substr($hash, $i, 2); } $scrape = file_get_contents($tracker); $bencode = new BEncodeLib(); $info = $bencode->bdecode($scrape); $ul = intval($info['files'][pack("H*", $hash)]['complete']); $dl = intval($info['files'][pack("H*", $hash)]['incomplete']); mysql_query("INSERT INTO torrents (added,hash,name,seeds,peers,size,tracker,maincat,subcat,registration) VALUES ('$date','$hash','$name','$ul','$dl','$size','$tracker','$maincat','$subcat','$registration')"); mysql_query("UPDATE categories SET torrents = torrents+1 WHERE subid = '$subcat'"); move_uploaded_file($_FILES['torrent']['tmp_name'], 'data/'.$hash.'.torrent'); echo 'Thanks, Torrent is uploaded'; die; } } } else { stheader('Upload a Torrent'); ?>
Torrent:
Filename:
Category:
Private Tracker: Yes No