-
Notifications
You must be signed in to change notification settings - Fork 28
/
delete.php
125 lines (124 loc) · 6.91 KB
/
delete.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/**
|--------------------------------------------------------------------------|
| https://github.com/Bigjoos/ |
|--------------------------------------------------------------------------|
| Licence Info: GPL |
|--------------------------------------------------------------------------|
| Copyright (C) 2010 U-232 V4 |
|--------------------------------------------------------------------------|
| A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon. |
|--------------------------------------------------------------------------|
| Project Leaders: Mindless,putyn. |
|--------------------------------------------------------------------------|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e )
\_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
*/
require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'bittorrent.php');
require_once (INCL_DIR . 'user_functions.php');
require_once (INCL_DIR . 'function_memcache.php');
dbconn();
loggedinorreturn();
$lang = array_merge(load_language('global') , load_language('delete'));
if (!mkglobal("id")) stderr("{$lang['delete_failed']}", "{$lang['delete_missing_data']}");
$id = 0 + $id;
if (!is_valid_id($id)) stderr("{$lang['delete_failed']}", "{$lang['delete_missing_data']}");
//==delete torrents by putyn
function deletetorrent($id)
{
global $INSTALLER09, $mc1, $CURUSER, $lang;
sql_query("DELETE peers.*, files.*, comments.*, snatched.*, thanks.*, bookmarks.*, coins.*, rating.*, torrents.* FROM torrents
LEFT JOIN peers ON peers.torrent = torrents.id
LEFT JOIN files ON files.torrent = torrents.id
LEFT JOIN comments ON comments.torrent = torrents.id
LEFT JOIN thanks ON thanks.torrentid = torrents.id
LEFT JOIN bookmarks ON bookmarks.torrentid = torrents.id
LEFT JOIN coins ON coins.torrentid = torrents.id
LEFT JOIN rating ON rating.torrent = torrents.id
LEFT JOIN snatched ON snatched.torrentid = torrents.id
LEFT JOIN thumbsup ON thumbsup.torrentid = torrents.id
WHERE torrents.id =" . sqlesc($id)) or sqlerr(__FILE__, __LINE__);
unlink("{$INSTALLER09['torrent_dir']}/$id.torrent");
$mc1->delete_value('MyPeers_' . $CURUSER['id']);
}
function deletetorrent_xbt($id)
{
global $INSTALLER09, $mc1, $CURUSER, $lang;
sql_query("UPDATE torrents SET flags = 1 WHERE id = ".sqlesc($id)) or sqlerr(__FILE__, __LINE__);
sql_query("DELETE files.*, comments.*, thankyou.*, thanks.*, thumbsup.*, bookmarks.*, coins.*, rating.*, xbt_files_users.* FROM xbt_files_users
LEFT JOIN files ON files.torrent = xbt_files_users.fid
LEFT JOIN comments ON comments.torrent = xbt_files_users.fid
LEFT JOIN thankyou ON thankyou.torid = xbt_files_users.fid
LEFT JOIN thanks ON thanks.torrentid = xbt_files_users.fid
LEFT JOIN bookmarks ON bookmarks.torrentid = xbt_files_users.fid
LEFT JOIN coins ON coins.torrentid = xbt_files_users.fid
LEFT JOIN rating ON rating.torrent = xbt_files_users.fid
LEFT JOIN thumbsup ON thumbsup.torrentid = xbt_files_users.fid
WHERE xbt_files_users.fid =" . sqlesc($id)) or sqlerr(__FILE__, __LINE__);
unlink("{$INSTALLER09['torrent_dir']}/$id.torrent");
$mc1->delete_value('MyPeers_XBT_' . $CURUSER['id']);
}
$res = sql_query("SELECT name, owner, seeders FROM torrents WHERE id =" . sqlesc($id));
$row = mysqli_fetch_assoc($res);
if (!$row) stderr("{$lang['delete_failed']}", "{$lang['delete_not_exist']}");
if ($CURUSER["id"] != $row["owner"] && $CURUSER["class"] < UC_STAFF) stderr("{$lang['delete_failed']}", "{$lang['delete_not_owner']}\n");
$rt = 0 + $_POST["reasontype"];
if (!is_int($rt) || $rt < 1 || $rt > 5) stderr("{$lang['delete_failed']}", "{$lang['delete_invalid']}");
$reason = $_POST["reason"];
if ($rt == 1) $reasonstr = "{$lang['delete_dead']}";
elseif ($rt == 2) $reasonstr = "{$lang['delete_dupe']}" . ($reason[0] ? (": " . trim($reason[0])) : "!");
elseif ($rt == 3) $reasonstr = "{$lang['delete_nuked']}" . ($reason[1] ? (": " . trim($reason[1])) : "!");
elseif ($rt == 4) {
if (!$reason[2]) stderr("{$lang['delete_failed']}", "{$lang['delete_violated']}");
$reasonstr = $INSTALLER09['site_name'] . "{$lang['delete_rules']}" . trim($reason[2]);
} else {
if (!$reason[3]) stderr("{$lang['delete_failed']}", "{$lang['delete_reason']}");
$reasonstr = trim($reason[3]);
}
if (XBT_TRACKER == true) {
deletetorrent_xbt($id);
} else {
deletetorrent($id);
remove_torrent_peers($id);
}
//$mc1->delete_value('lastest_tor_');
$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);
write_log("{$lang['delete_torrent']} $id ({$row['name']}){$lang['delete_deleted_by']}{$CURUSER['username']} ($reasonstr)\n");
if ($INSTALLER09['seedbonus_on'] == 1) {
//===remove karma
sql_query("UPDATE users SET seedbonus = seedbonus-".sqlesc($INSTALLER09['bonus_per_delete'])." WHERE id = " . sqlesc($row["owner"])) or sqlerr(__FILE__, __LINE__);
$update['seedbonus'] = ($CURUSER['seedbonus'] - $INSTALLER09['bonus_per_delete']);
$mc1->begin_transaction('userstats_' . $row["owner"]);
$mc1->update_row(false, array(
'seedbonus' => $update['seedbonus']
));
$mc1->commit_transaction($INSTALLER09['expires']['u_stats']);
$mc1->begin_transaction('user_stats_' . $row["owner"]);
$mc1->update_row(false, array(
'seedbonus' => $update['seedbonus']
));
$mc1->commit_transaction($INSTALLER09['expires']['user_stats']);
//===end
}
if ($CURUSER["id"] != $row["owner"] AND $CURUSER['pm_on_delete'] == 'yes') {
$added = TIME_NOW;
$pm_on = (int)$row["owner"];
$subject = 'Torrent Deleted';
$message = "Torrent $id (" . htmlsafechars($row['name']) . ") has been deleted.\n Reason: $reasonstr";
sql_query("INSERT INTO messages (subject, sender, receiver, msg, added) VALUES(" . sqlesc($subject) . ", 0, " . sqlesc($pm_on) . "," . sqlesc($message) . ", $added)") or sqlerr(__FILE__, __LINE__);
$mc1->delete_value('inbox_new_' . $pm_on);
$mc1->delete_value('inbox_new_sb_' . $pm_on);
}
if (isset($_POST["returnto"])) $ret = "<a href='" . htmlsafechars($_POST["returnto"]) . "'>{$lang['delete_go_back']}</a>";
else $ret = "<a href='{$INSTALLER09['baseurl']}/browse.php'>{$lang['delete_back_browse']}</a>";
$HTMLOUT = '';
$HTMLOUT.= "<h2>{$lang['delete_deleted']}</h2>
<p>$ret</p>";
echo stdhead("{$lang['delete_deleted']}") . $HTMLOUT . stdfoot();
?>