| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,182 @@ |
| 1 |
+<?php |
|
| 2 |
+require ("config.php");
|
|
| 3 |
+require_once ("funcsv2.php");
|
|
| 4 |
+//Check session |
|
| 5 |
+session_start(); |
|
| 6 |
+ |
|
| 7 |
+if (!$_SESSION['admin_logged_in']) |
|
| 8 |
+{
|
|
| 9 |
+ //check fails |
|
| 10 |
+ header("Location: authenticate.php?status=session");
|
|
| 11 |
+ exit(); |
|
| 12 |
+} |
|
| 13 |
+?> |
|
| 14 |
+ |
|
| 15 |
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
|
| 16 |
+ |
|
| 17 |
+<html> |
|
| 18 |
+<head> |
|
| 19 |
+ <title>Tracker User Statistics</title> |
|
| 20 |
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> |
|
| 21 |
+ <link rel="stylesheet" href="./css/style.css" type="text/css" /> |
|
| 22 |
+</head> |
|
| 23 |
+<body> |
|
| 24 |
+<h1>Tracker User Statistics</h1> |
|
| 25 |
+ |
|
| 26 |
+<form action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>" method="POST"> |
|
| 27 |
+Filename Search:<input type="text" name="filename_search" size="40"<?php if (isset($_POST["filename_search"]))echo " value=\"" . filterData($_POST["filename_search"]) . "\"";?>> |
|
| 28 |
+<input type="submit" value="Search"> |
|
| 29 |
+</form> |
|
| 30 |
+<br> |
|
| 31 |
+ |
|
| 32 |
+<?php |
|
| 33 |
+require_once ("config.php");
|
|
| 34 |
+require_once ("funcsv2.php");
|
|
| 35 |
+ |
|
| 36 |
+//connect to database and grab each torrent in database |
|
| 37 |
+if ($GLOBALS["persist"]) |
|
| 38 |
+ $db = mysql_pconnect($dbhost, $dbuser, $dbpass) or die(errorMessage() . "Tracker error: can't connect to database - " . mysql_error() . "</p>"); |
|
| 39 |
+else |
|
| 40 |
+ $db = mysql_connect($dbhost, $dbuser, $dbpass) or die(errorMessage() . "Tracker error: can't connect to database - " . mysql_error() . "</p>"); |
|
| 41 |
+mysql_select_db($database) or die(errorMessage() . "Tracker error: can't open database $database - " . mysql_error() . "</p>"); |
|
| 42 |
+ |
|
| 43 |
+//Display search information |
|
| 44 |
+if (isset($_POST["filename_search"]) && $_POST["filename_search"] != "") |
|
| 45 |
+{
|
|
| 46 |
+ echo "<h2 align=\"center\">Search Results:</h2>"; |
|
| 47 |
+ $query = "SELECT * FROM ".$prefix."summary LEFT JOIN ".$prefix."namemap ON ".$prefix."summary.info_hash = ".$prefix."namemap.info_hash WHERE ".$prefix."namemap.filename REGEXP \"$_POST[filename_search]\" ORDER BY ".$prefix."namemap.filename"; |
|
| 48 |
+} |
|
| 49 |
+else //display everything |
|
| 50 |
+{
|
|
| 51 |
+ $scriptname = htmlentities($_SERVER['PHP_SELF']) . "?"; |
|
| 52 |
+ |
|
| 53 |
+ if (!isset($_GET["activeonly"])) |
|
| 54 |
+ echo "<a href=\"$scriptname" . "activeonly=yes\">Show only torrents with seeders/leechers</a>\n"; |
|
| 55 |
+ else |
|
| 56 |
+ {
|
|
| 57 |
+ echo "<a href=\"$scriptname\">Show all torrents</a>\n"; |
|
| 58 |
+ $scriptname = $scriptname . "activeonly=yes&"; |
|
| 59 |
+ } |
|
| 60 |
+ |
|
| 61 |
+ if (isset($_GET["activeonly"])) |
|
| 62 |
+ $where = " WHERE leechers+seeds > 0"; |
|
| 63 |
+ else |
|
| 64 |
+ $where = " "; |
|
| 65 |
+ |
|
| 66 |
+ $query = "SELECT COUNT(*) FROM ".$prefix."summary $where"; |
|
| 67 |
+ $results = mysql_query($query); |
|
| 68 |
+ $res = mysql_result($results,0,0); |
|
| 69 |
+ |
|
| 70 |
+ echo "<p align='center'>Page: \n"; |
|
| 71 |
+ $count = 0; |
|
| 72 |
+ $page = 1; |
|
| 73 |
+ while($count < $res) |
|
| 74 |
+ {
|
|
| 75 |
+ if (isset($_GET["page_number"]) && $page == $_GET["page_number"]) |
|
| 76 |
+ echo "<b><a href=\"$scriptname" . "page_number=$page\">($page)</a></b>-\n"; |
|
| 77 |
+ else if (!isset($_GET["page_number"]) && $page == 1) |
|
| 78 |
+ echo "<b><a href=\"$scriptname" . "page_number=$page\">($page)</a></b>-\n"; |
|
| 79 |
+ else |
|
| 80 |
+ echo "<a href=\"$scriptname" . "page_number=$page\">$page</a>-\n"; |
|
| 81 |
+ $page++; |
|
| 82 |
+ $count = $count + ($GLOBALS["statspagelimitspecify"]); |
|
| 83 |
+ } |
|
| 84 |
+ echo "</p>\n"; |
|
| 85 |
+ |
|
| 86 |
+ if (!isset($_GET["page_number"])) |
|
| 87 |
+ $query = "SELECT * FROM ".$prefix."summary LEFT JOIN ".$prefix."namemap ON ".$prefix."summary.info_hash = ".$prefix."namemap.info_hash $where ORDER BY ".$prefix."namemap.filename LIMIT 0,${GLOBALS['statspagelimitspecify']}";
|
|
| 88 |
+ else |
|
| 89 |
+ {
|
|
| 90 |
+ $page_limit = ($_GET["page_number"] - 1) * ($GLOBALS["statspagelimitspecify"]); |
|
| 91 |
+ $query = "SELECT * FROM ".$prefix."summary LEFT JOIN ".$prefix."namemap ON ".$prefix."summary.info_hash = ".$prefix."namemap.info_hash $where ORDER BY ".$prefix."namemap.filename LIMIT $page_limit,${GLOBALS['statspagelimitspecify']}";
|
|
| 92 |
+ } |
|
| 93 |
+} |
|
| 94 |
+ |
|
| 95 |
+$results = mysql_query($query) or die(errorMessage() . "Can't do SQL query - " . mysql_error() . "</p>"); |
|
| 96 |
+ |
|
| 97 |
+while ($data = mysql_fetch_row($results)) |
|
| 98 |
+{
|
|
| 99 |
+ $xhash = "x" . $data[0]; |
|
| 100 |
+ $query2 = "SELECT * FROM ".$prefix."$xhash"; |
|
| 101 |
+ $results2 = mysql_query($query2) or die(errorMessage() . "Can't do SQL query - " . mysql_error() . "</p>"); |
|
| 102 |
+ |
|
| 103 |
+ if (mysql_num_rows($results2) == 0 && isset($_GET["activeonly"])) |
|
| 104 |
+ break; |
|
| 105 |
+ else |
|
| 106 |
+ {
|
|
| 107 |
+ echo "<hr><table>\n"; |
|
| 108 |
+ echo "<tr><th>Info Hash</th><th>Filename</th><th>URL</th><th>File Size</th><th>Publication Date</th></tr>\n"; |
|
| 109 |
+ echo "<tr><td>" . $data[0] . "</td><td>" . $data[12] . "</td><td>\n"; |
|
| 110 |
+ if (Substr($data[13], 0, 7) == "http://") |
|
| 111 |
+ echo "<a href=\"" . $data[13] . "\">" . $data[13] . "</a>\n"; |
|
| 112 |
+ else |
|
| 113 |
+ echo $data[13]; |
|
| 114 |
+ echo "</td><td>" . bytesToString($data[14]) . "</td>\n"; |
|
| 115 |
+ echo "<td>" . $data[15] . "</td></tr>\n"; |
|
| 116 |
+ echo "</table>\n"; |
|
| 117 |
+ } |
|
| 118 |
+ |
|
| 119 |
+ echo "<table>\n"; |
|
| 120 |
+ echo "<tr><th class=\"subheader\">IP Address</th><th class=\"subheader\">Data Left to Download</th><th class=\"subheader\" width=200>Percent Finished</th><th class=\"subheader\">Port</th><th class=\"subheader\">Last Update</th><th class=\"subheader\">NAT User</th></tr>\n"; |
|
| 121 |
+ while ($data2 = mysql_fetch_row($results2)) |
|
| 122 |
+ {
|
|
| 123 |
+ //grab information on each user |
|
| 124 |
+ echo "<tr><td>" . $data2[2] . "</td>\n"; |
|
| 125 |
+ echo "<td>" . bytesToString($data2[1]) . "</td>\n"; |
|
| 126 |
+ |
|
| 127 |
+ //calculate percent done for user |
|
| 128 |
+ $percent_done = 1.00; |
|
| 129 |
+ if ($data2[1] != 0) //only run calculation if they are still downloading |
|
| 130 |
+ {
|
|
| 131 |
+ $size_in_bytes = $data[14]; |
|
| 132 |
+ if ($size_in_bytes == 0) //thou shalt not divide by zero |
|
| 133 |
+ $percent_done = 0; |
|
| 134 |
+ else |
|
| 135 |
+ $percent_done = round(($size_in_bytes - $data2[1]) / $size_in_bytes, 3); |
|
| 136 |
+ } |
|
| 137 |
+ |
|
| 138 |
+ ?> |
|
| 139 |
+ <td> |
|
| 140 |
+ <table class="percentages" cellspacing="0"> |
|
| 141 |
+ <tr> |
|
| 142 |
+ <td align="right" class="percent" width="<?php echo round($percent_done * 200, 0); ?>" height="15"> |
|
| 143 |
+ <?php if ($percent_done > .5) echo $percent_done * 100 . "%"; ?> |
|
| 144 |
+ </td> |
|
| 145 |
+ <td align="left" class="percentleft" width="<?php echo 200 - round($percent_done * 200, 0); ?>" height="15"> |
|
| 146 |
+ <?php if ($percent_done <= .5) echo $percent_done * 100 . "%"; ?> |
|
| 147 |
+ </td> |
|
| 148 |
+ </tr> |
|
| 149 |
+ </table> |
|
| 150 |
+ </td> |
|
| 151 |
+ <?php |
|
| 152 |
+ echo "<td>" . $data2[3] . "</td>\n"; //port |
|
| 153 |
+ echo "<td>" . date('g:ia m-d-Y', $data2[5]) . "</td>\n"; //last time check-in
|
|
| 154 |
+ echo "<td>" . $data2[7] . "</td>\n"; //NAT user |
|
| 155 |
+ echo "</tr>\n"; |
|
| 156 |
+ } |
|
| 157 |
+ echo "</table><br>\n"; |
|
| 158 |
+} |
|
| 159 |
+echo "<hr>"; |
|
| 160 |
+if (!isset($_POST["filename_search"])) |
|
| 161 |
+{
|
|
| 162 |
+ echo "<p align='center'>Page: \n"; |
|
| 163 |
+ $count = 0; |
|
| 164 |
+ $page = 1; |
|
| 165 |
+ while($count < $res) |
|
| 166 |
+ {
|
|
| 167 |
+ if (isset($_GET["page_number"]) && $page == $_GET["page_number"]) |
|
| 168 |
+ echo "<b><a href=\"$scriptname" . "page_number=$page\">($page)</a></b>-\n"; |
|
| 169 |
+ else if (!isset($_GET["page_number"]) && $page == 1) |
|
| 170 |
+ echo "<b><a href=\"$scriptname" . "page_number=$page\">($page)</a></b>-\n"; |
|
| 171 |
+ else |
|
| 172 |
+ echo "<a href=\"$scriptname" . "page_number=$page\">$page</a>-\n"; |
|
| 173 |
+ $page++; |
|
| 174 |
+ $count = $count + ($GLOBALS["statspagelimitspecify"]); |
|
| 175 |
+ } |
|
| 176 |
+ echo "</p>\n"; |
|
| 177 |
+} |
|
| 178 |
+?> |
|
| 179 |
+ |
|
| 180 |
+<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> |
|
| 181 |
+</body> |
|
| 182 |
+</html> |