function remove_torrent($infohash) { global $mc1; if (strlen($infohash) != 40 || !bin2hex($infohash)) { return false; } $key = 'torrent::hash:::' . md5($infohash); $torrent = $mc1->get_value($key); if ($torrent === false) { return false; } $mc1->delete_value($key); if (is_array($torrent)) { remove_torrent_peers($torrent['id']); } return true; }
function delete_torrent($delete_array, $page) { global $INSTALLER09, $CURUSER, $mc1, $lang; if (empty($delete_array)) { return false; } $delete = array(); foreach ($delete_array as $remove) { $delete[] = 0 + $remove; } $delete = array_unique($delete); $count = count($delete); if (!$count) { return false; } if ($count > 25) { die(' ' . $lang['deathrow_try'] . ' (' . $count . ').'); } $res = sql_query('SELECT id, added, name, owner, seeders, info_hash FROM torrents ' . 'WHERE id IN (' . implode(', ', $delete) . ')') or sqlerr(__FILE__, __LINE__); while ($row = mysqli_fetch_assoc($res)) { if (!(($CURUSER['id'] == $row['owner'] || $CURUSER['class'] >= UC_STAFF) && $row['seeders'] == 0)) { continue; } $ids[] = $row['id']; $names[] = htmlsafechars($row['name']); $id = (int) $row['id']; /** unlink() **/ unlink("{$INSTALLER09['torrent_dir']}/{$id}.torrent"); // announce remove_torrent_peers($id); remove_torrent($row['info_hash']); // index_last5_posters $mc1->delete_value('last5_tor_'); $mc1->delete_value('top5_tor_'); $mc1->delete_value('scroll_tor_'); // torrent_details $mc1->delete_value('torrent_details_' . $id); $mc1->delete_value('torrent_xbt_data_' . $id); $mc1->delete_value('torrent_details_txt' . $id); $mc1->delete_value('coin_points_' . $id); $mc1->delete_value('similiar_tor_' . $id); $dt = sqlesc(TIME_NOW - 14 * 86400); // lose karma if deleted within 2 weeks if ($row['added'] < $dt) { sql_query("UPDATE users SET seedbonus = seedbonus-15.0 WHERE id = " . sqlesc($row['owner'])) or sqlerr(__FILE__, __LINE__); } } $unique_ids = array_unique($ids); $countids = count($unique_ids); if ($countids > 0) { sql_query('DELETE FROM torrents WHERE id IN (' . implode(', ', $ids) . ')'); foreach (explode(".", "bookmarks.snatched.thanks.thankyou.coins") as $y) { sql_query('DELETE FROM ' . $y . ' WHERE torrentid IN (' . implode(', ', $ids) . ')'); } foreach (explode(".", "peers.files.comments.rating") as $x) { sql_query('DELETE FROM ' . $x . ' WHERE torrent IN (' . implode(', ', $ids) . ')'); } sql_query('DELETE FROM deathrow WHERE tid IN (' . implode(', ', $ids) . ')') or sqlerr(__FILE__, __LINE__); sql_query('DELETE FROM thanks WHERE torrentid IN (' . implode(', ', $ids) . ')') or sqlerr(__FILE__, __LINE__); sql_query('DELETE FROM thankyou WHERE torid IN (' . implode(', ', $ids) . ')') or sqlerr(__FILE__, __LINE__); write_log(' ' . $lang['deathrow_torr'] . ' (' . implode(', ', $names) . '.) ' . $lang['deathrow_were'] . ' ' . $CURUSER['username'] . ' (' . $page . ')' . "\n"); return $countids; } else { return false; } }
unlink("{$INSTALLER09['torrent_dir']}/{$id}.torrent"); $mc1->delete_value('MyPeers_XBT_' . $CURUSER['id']); } $q = mysqli_fetch_assoc(sql_query("SELECT name, owner FROM torrents WHERE id =" . sqlesc($id))) or sqlerr(__FILE__, __LINE__); if (!$q) { stderr('Oopps', 'Something went Pete Tong - Contact admin !!'); } $sure = isset($_GET['sure']) && (int) $_GET['sure']; if (!$sure) { stderr("{$lang['fastdelete_sure']}", "{$lang['fastdelete_sure_msg']}"); } if (XBT_TRACKER == true) { deletetorrent_xbt($id); } else { deletetorrent($id); remove_torrent_peers($id); } $mc1->delete_value('top5_tor_'); $mc1->delete_value('last5_tor_'); $mc1->delete_value('scroll_tor_'); $mc1->delete_value('torrent_details_' . $id); $mc1->delete_value('torrent_details_text' . $id); if ($CURUSER['id'] != $q['owner']) { $msg = sqlesc("{$lang['fastdelete_msg_first']} [b]{$q['name']}[/b] {$lang['fastdelete_msg_last']} {$CURUSER['username']}"); sql_query("INSERT INTO messages (sender, receiver, added, msg) VALUES (0, " . sqlesc($q['owner']) . ", " . TIME_NOW . ", {$msg})") or sqlerr(__FILE__, __LINE__); } write_log("{$lang['fastdelete_log_first']} {$q['name']} {$lang['fastdelete_log_last']} {$CURUSER['username']}"); if ($INSTALLER09['seedbonus_on'] == 1) { //===remove karma sql_query("UPDATE users SET seedbonus = seedbonus-" . sqlesc($INSTALLER09['bonus_per_delete']) . " WHERE id = " . sqlesc($q["owner"])) or sqlerr(__FILE__, __LINE__); $update['seedbonus'] = $CURUSER['seedbonus'] - $INSTALLER09['bonus_per_delete'];