This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeleter.php
132 lines (120 loc) · 5.17 KB
/
deleter.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
126
127
128
129
130
131
132
<?php
require ("config.php");
//Check session
session_start();
if (!$_SESSION['admin_logged_in'])
{
//check fails
header("Location: authenticate.php?status=session");
exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Delete Torrent(s) From Database</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="./css/style.css" />
<script language="javascript">
function selectRow(checkBox)
{
if (checkBox.value % 2 == 1) //odd
var Style = "row1";
else //even
var Style = "row0";
if (checkBox.checked == true)
var Style = "selected";
var el = checkBox.parentNode;
while(el.tagName.toLowerCase() != "tr")
{
el = el.parentNode;
}
el.className = Style;
}
</script>
</head>
<body>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>" method="POST">
<?php
require_once("funcsv2.php");
// check database user
if (isset($dbuser) && isset($dbpass))
{
$db = mysql_connect($dbhost, $dbuser, $dbpass) or die(errorMessage() . "Cannot connect to database. Check your username and password in the config file.</p>");
mysql_select_db($database) or die(errorMessage() . "Error selecting database.</p>");
foreach ($_POST as $left => $right)
{
if (strlen($left) == 41)
{
if (!is_numeric($right) || !verifyHash(substr($left, 1)))
continue;
$hash = substr($left, 1);
//delete torrent file
$query = "SELECT filename FROM ".$prefix."namemap WHERE info_hash =\"$hash\"";
$delete_file = mysql_query($query) or die(errorMessage() . "Can't do SQL query - " . mysql_error() . "</p>");
$delete = mysql_fetch_row($delete_file);
unlink("torrents/" . $delete[0] . ".torrent");
//continue deleting information in database
@mysql_query("DELETE FROM " . $prefix . "summary WHERE info_hash=\"$hash\"");
@mysql_query("DELETE FROM " . $prefix . "namemap WHERE info_hash=\"$hash\"");
@mysql_query("DELETE FROM " . $prefix . "timestamps WHERE info_hash=\"$hash\"");
@mysql_query("DELETE FROM " . $prefix . "webseedfiles WHERE info_hash=\"$hash\"");
@mysql_query("DROP TABLE " . $prefix . "y$hash");
@mysql_query("DROP TABLE " . $prefix . "x$hash");
//optimize tables, good after major changes have been made to database
@mysql_query("OPTIMIZE TABLE " . $prefix . "summary");
@mysql_query("OPTIMIZE TABLE " . $prefix . "namemap");
@mysql_query("OPTIMIZE TABLE " . $prefix . "timestamps");
//run RSS generator
require_once("rss_generator.php");
}
}
}
else
{
$db = mysql_connect($dbhost, $dbuser, $dbpass) or die(errorMessage() . "Tracker error: can't connect to database - " . mysql_error() . "</p>");
mysql_select_db($database) or die(errorMessage() . "Tracker error: can't open database $database - " . mysql_error() . "</p>");
$GLOBALS["maydelete"] = false;
}
?>
<h1>Delete Torrent(s) From Database</h1>
<table class="torrentlist" cellspacing="1">
<tr>
<th>Name/Info Hash</th>
<th>File Size</th>
<th>Seeders</th>
<th>Leechers</th>
<th>Completed D/Ls</th>
<th>Bytes Transfered</th>
<th>Delete?</th>
</tr>
<?php
if ($GLOBALS["customtitle"] != "true")
$results = mysql_query("SELECT ".$prefix."summary.info_hash, ".$prefix."namemap.size, ".$prefix."summary.seeds, ".$prefix."summary.leechers, format(".$prefix."summary.finished,0), format(".$prefix."summary.dlbytes/1073741824,3), ".$prefix."namemap.filename FROM ".$prefix."summary LEFT JOIN ".$prefix."namemap ON ".$prefix."summary.info_hash = ".$prefix."namemap.info_hash ORDER BY ".$prefix."namemap.filename") or die(errorMessage() . "" . mysql_error() . "</p>");
else $results = mysql_query("SELECT ".$prefix."summary.info_hash, ".$prefix."namemap.size, ".$prefix."summary.seeds, ".$prefix."summary.leechers, format(".$prefix."summary.finished,0), format(".$prefix."summary.dlbytes/1073741824,3), ".$prefix."namemap.title FROM ".$prefix."summary LEFT JOIN ".$prefix."namemap ON ".$prefix."summary.info_hash = ".$prefix."namemap.info_hash ORDER BY ".$prefix."namemap.title") or die(errorMessage() . "" . mysql_error() . "</p>");
$i = 0;
while ($data = mysql_fetch_row($results)) {
$writeout = "row" . $i % 2;
$hash = $data[0];
if (is_null($data[6]))
$data[6] = $data[0];
if (strlen($data[6]) == 0)
$data[6] = $data[0];
echo "<tr class=\"$writeout\">\n";
echo "\t<td>".$data[6]."</td>\n";
echo "\t<td>".bytesToString($data[1])."</td>\n";
for ($j=2; $j < 5; $j++)
echo "\t<td class=\"center\">$data[$j]</td>\n";
echo "\t<td class=\"center\">$data[5] GB</td>\n";
echo "\t<td class=\"center\"><input type=\"checkbox\" name=\"x$hash\" value=\"$i\" onclick=\"selectRow(this);\"/></td>\n";
echo "</tr>\n";
$i++;
}
?>
</table>
<p class="error">Warning: there is no confirmation for deleting files. Clicking this button is final.</p>
<p class="center"><input type="submit" value="Delete" /></p>
</form>
<a href="index.php"><img src="images/stats.png" border="0" class="icon" alt="Tracker Statistics" title="Tracker Statistics" /></a><a href="index.php">Return to Statistics Page</a><br>
<a href="admin.php"><img src="images/admin.png" border="0" class="icon" alt="Admin Page" title="Admin Page" /></a><a href="admin.php">Return to Admin Page</a>
</body></html>