From 5fd9fa480f302902328b81f912dd67ce378284f8 Mon Sep 17 00:00:00 2001 From: citizenz7 Date: Thu, 20 Apr 2017 18:50:55 +0200 Subject: V.1.4.6 --- Html/admin/download.php | 90 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Html/admin/download.php (limited to 'Html/admin/download.php') diff --git a/Html/admin/download.php b/Html/admin/download.php new file mode 100644 index 0000000..136cc35 --- /dev/null +++ b/Html/admin/download.php @@ -0,0 +1,90 @@ +prepare('SELECT * FROM blog_members WHERE username = :username'); + $stmt->execute(array(':username' => html($_SESSION['username']))); + $row = $stmt->fetch(); + $uid = $row['memberID']; +} +else { + // s'il n'y a pas de session, c'est donc un visiteur avec l'id 32 + $uid = 32; +} + +/* +//on recherche le hash dans la base xbt_files +$stmt1 = $db->prepare('SELECT * FROM xbt_files WHERE fid = :fid'); +$stmt1->execute(array(':fid' => $fid)); +$row1 = $stmt1->fetch(); +*/ + +//on recherche le torrent dans la base blog_posts_seo +$stmt2 = $db->prepare('SELECT * FROM blog_posts_seo WHERE postID = :postID'); +$stmt2->execute(array(':postID' => $fid)); +$row2 = $stmt2->fetch(); + +if($row2['postID'] == '') { + header('Location: '.SITEURL.'/torrents.php?action=noexist'); +} + + +$torrent = $row2['postTorrent']; + +$torrentfile = $REP_TORRENTS.'/'.$torrent; + +// On décode le fichier torrent +$fd = fopen($torrentfile, "rb"); +$alltorrent = fread($fd, filesize($torrentfile)); +$array = BDecode($alltorrent); +fclose($fd); + +//On cherche le pid +$stmt3 = $db->prepare('SELECT * FROM blog_members WHERE memberID = :uid'); +$stmt3->execute(array(':uid' => $uid)); +$row3 = $stmt3->fetch(); + +// Il n'y a que les membres + les visiteurs qui peuvent télécharger +// pas de userid = 0 +if ($row3['pid'] == '') { + header('Location: '.SITEURL); +} + +if ($row3['pid'] == '00000000000000000000000000000000') { + $pid = '00000000000000000000000000000000'; +} +else { + $pid = $row3['pid']; +} + +$tracker_announce_urls = SITEURL.':'.ANNOUNCEPORT.'/announce'; + +// On construit la nouvelle announce avec le pid (passkey ...) +$array["announce"] = SITEURL.":".ANNOUNCEPORT."/".$pid."/announce"; + +$alltorrent=BEncode($array); + +// On construit le header +header("Content-Type: application/x-bittorrent"); +header('Content-Disposition: attachment; filename="['.SITENAMELONG.']'.$torrent.'"'); +print($alltorrent); + +if(isset($_SESSION['username'])) { + write_log('Download torrent : '.html($row2['postTitle']).' par '.html($_SESSION['username']), $db); +} +else { + write_log('Download torrent : '.html($row2['postTitle']).' par Visiteur', $db); +} + +?> -- cgit v1.2.1