-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathview.php
executable file
·291 lines (268 loc) · 15.6 KB
/
view.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<?php
//
// This file is part of rtGui. http://rtgui.googlecode.com/
// Copyright (C) 2007-2011 Simon Hall.
//
// rtGui is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rtGui is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with rtGui. If not, see <http://www.gnu.org/licenses/>.
$execstart=$start=microtime(true);
include "functions.php";
include "config.php";
//import_request_variables("gp","r_");
$r_select = isset($_GET['select']) ? trim($_GET['select']) : 'files';
$r_hash = isset($_GET['hash']) ? trim($_GET['hash']) : null;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="favicon.ico" />
<title>rtGui</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class='modal'>
<?php
// Get torrent info... (get all downloads, then filter out just this one by the hash)
$alltorrents=get_full_list("main");
$thistorrent=array();
foreach($alltorrents as $torrent) {
if ($r_hash==$torrent['hash']) $thistorrent=$torrent;
}
if ($thistorrent['complete']==1) { $statusstyle="complete"; } else { $statusstyle="incomplete"; }
if ($thistorrent['is_active']==1) { $statusstyle.="active"; } else { $statusstyle.="inactive"; }
echo "<h3 class='".$statusstyle."' align='center'>".mb_wordwrap($thistorrent['name'],52,"<br/>\n",TRUE)."</h3>\n";
// Controls (stop/start/hash check etc)...
echo "<div class='controlcontainer'>\n";
if ($thistorrent['is_active']==1) {
echo "<input type=button value='Stop' class='buttonstop' onClick='window.location=\"control.php?hash=".$thistorrent['hash']."&cmd=stop\"' />\n";
} else {
echo "<input type=button value='Start' class='buttonstart' onClick='window.location=\"control.php?hash=".$thistorrent['hash']."&cmd=start\"' />\n";
}
echo "<input type=button value='Delete' class='buttondel' onClick='if (confirm(\"Delete torrent - are you sure? (This will not delete data from disk)\")) parent.location=\"control.php?hash=".$thistorrent['hash']."&cmd=delete\"' />\n";
echo "<input type=button value='Hash check' class='buttonhashcheck' onClick='window.location=\"control.php?hash=".$thistorrent['hash']."&cmd=hashcheck\"' />\n";
echo "<input type=button value='Refresh' class='buttonrefresh' onClick='window.location=\"view.php?select=$r_select&hash=".$thistorrent['hash']."\"' />\n";
echo "</div>\n"; // end of controlcontainer div
echo "<p> </p>";
// Select view...
echo "<div id='navcontainer' style='width:552px'>\n";
echo "<ul id='navlist'>\n";
echo "<li><a ".($r_select=="files" ? "id='current'" : "")." href='?select=files&hash=$r_hash'>Files</a></li>\n";
echo "<li><a ".($r_select=="tracker" ? "id='current'" : "")." href='?select=tracker&hash=$r_hash'>Tracker</a></li>\n";
echo "<li><a ".($r_select=="peers" ? "id='current'" : "")." href='?select=peers&hash=$r_hash'>Peers</a></li>\n";
echo "<li><a ".($r_select=="torrent" ? "id='current'" : "")." href='?select=torrent&hash=$r_hash'>Torrent</a></li>\n";
echo "<li><a ".($r_select=="storage" ? "id='current'" : "")." href='?select=storage&hash=$r_hash'>Storage</a></li>\n";
if ($debugtab) {
echo "<li><a ".($r_select=="debug" ? "id='current'" : "")." href='?select=debug&hash=$r_hash'>Debug</a></li>\n";
}
echo "</ul>\n";
echo "</div>\n";
// Display file info...
if ($r_select=="files") {
$data=get_file_list($r_hash);
echo "<div class='container' style='width:550px'>\n";
echo "<div class='headcol' style='width:190px;'>Filename</div>\n";
echo "<div class='headcol' style='width:90px;'>Size</div>\n";
echo "<div class='headcol' style='width:90px;'>Done</div>\n";
echo "<div class='headcol' style='width:90px;'>Chunks</div>\n";
echo "<div class='headcol' style='width:90px;'>Priority</div>\n";
$thisrow="row1";
$index=0;
echo "<form action='control.php' method=post>\n";
foreach($data AS $item) {
echo "<div class='$thisrow'>\n";
echo "<div class='namecol'>\n";
echo mb_wordwrap($item['path'],90,"<br/>\n",TRUE);
echo "</div>\n";
echo "<div class='floatright'>";
echo "<div class='datacol smalltext' style='width:90px;'>".format_bytes($item['size_bytes'])."</div>\n";
echo "<div class='datacol smalltext' style='width:90px;'>";
echo @round(($item['completed_chunks']/$item['size_chunks'])*100)." %<br/>\n";
echo percentbar(@round((($item['completed_chunks']/$item['size_chunks'])*100)/2));
echo "</div>\n";
echo "<div class='datacol smalltext' style='width:90px;'>".$item['completed_chunks']." / ".$item['size_chunks']."</div>\n";
echo "<div class='datacollast smalltext' style='width:90px;'>";
echo "<select name='set_fpriority[$index]' class='smalltext'>\n";
echo "<option value='0' ".($item['priority']==0 ? "selected" : "").">Off</option>\n";
echo "<option value='1' ".($item['priority']==1 ? "selected" : "").">Normal</option>\n";
echo "<option value='2' ".($item['priority']==2 ? "selected" : "").">High</option>\n";
echo "</select>\n";
echo "<input type='hidden' name='hash' value='$r_hash' />\n";
echo "</div>\n";
echo "</div>\n"; // end floatright div
echo "<div class='spacer'> </div>\n";
echo "</div>\n"; // end of $thisrow div
if ($thisrow=="row1") {$thisrow="row2";} else {$thisrow="row1";}
$index++;
}
echo "<div align='right' class='bottomtab'>\n";
echo "<input type='submit' value='Save' />";
echo "</div>\n";
echo "</form>\n";
echo "</div>\n"; // end container div
}
// tracker info...
if ($r_select=="tracker") {
$data=get_tracker_list($r_hash);
echo "<div class='container' style='width:550px'>\n";
echo "<div class='headcol' style='width:156px;'>URL</div>\n";
echo "<div class='headcol' style='width:124px;'>Last</div>\n";
echo "<div class='headcol' style='width:90px;'>Interval</div>\n";
echo "<div class='headcol' style='width:90px;'>Seed/Leech</div>\n";
echo "<div class='headcol' style='width:90px;'>Enabled</div>\n";
$thisrow="row1";
foreach($data AS $item) {
echo "<div class='$thisrow'>\n";
echo "<div class='namecol'>\n";
echo mb_wordwrap($item['url'],90,"<br/>\n",TRUE);
echo "</div>\n";
echo "<div class='floatright'>";
echo "<div class='datacol smalltext' style='width:124px;'>".($item['scrape_time_last']>0 ? date("Y-m-d
H:i",$item['scrape_time_last']) : "never")."</div>\n";
echo "<div class='datacol smalltext' style='width:90px;'>".@round($item['normal_interval']/60)."</div>\n";
echo "<div class='datacol smalltext' style='width:90px;'>".$item['scrape_complete']." / ".$item['scrape_incomplete']."</div>\n";
echo "<div class='datacollast smalltext' style='width:90px;'>".($item['is_enabled']==1 ? "Yes" : "No")."</div>\n";
echo "</div>\n"; // end floatright div
echo "<div class='spacer'> </div>\n";
echo "</div>\n"; // end of $thisrow div
if ($thisrow=="row1") {$thisrow="row2";} else {$thisrow="row1";}
}
echo "<div class='bottomthin'> </div>\n";
echo "</div>\n"; // end container div
}
// Peers info...
if ($r_select=="peers") {
$data=get_peer_list($r_hash);
echo "<div class='container' style='width:550px'>\n";
echo "<div class='headcol' style='width:190px;'>Address</div>\n";
echo "<div class='headcol' style='width:90px;'>Complete</div>\n";
echo "<div class='headcol' style='width:90px;'>Download</div>\n";
echo "<div class='headcol' style='width:90px;'>Upload</div>\n";
echo "<div class='headcol' style='width:90px;'>Peer</div>\n";
$thisrow="row1";
foreach($data AS $item) {
echo "<div class='$thisrow'>\n";
echo "<div class='namecol smalltext'>\n";
echo "<a href='http://www.who.is/whois-ip/ip-address/".$item['address']."/' target='_blank'>".gethostbyaddr($item['address'])."</a>";
echo ":".$item['port']." <i>".$item['client_version']."</i>";
$flags=($item['is_encrypted'] ? "enc " : "").($item['is_incoming'] ? "inc " : "").($item['is_obfuscated'] ? "obs " : "").($item['is_snubbed'] ? "snb " : "");
echo ($flags!="" ? " Flags: ".$flags : "");
echo "</div>\n";
echo "<div class='floatright'>";
echo "<div class='datacol smalltext' style='width:90px;'> ".$item['completed_percent']. "%<br/>".percentbar(@round($item['completed_percent'])/2)."</div>\n";
echo "<div class='datacol smalltext download' style='width:90px;'> ".($item['down_rate']>0 ? format_bytes($item['down_rate'])."/sec<br/>" : "").format_bytes($item['down_total'])."</div>\n";
echo "<div class='datacol smalltext upload' style='width:90px;'> ".($item['up_rate']>0 ? format_bytes($item['up_rate'])."/sec<br/>" : "").format_bytes($item['up_total'])."</div>\n";
echo "<div class='datacollast smalltext' style='width:90px;'> ".($item['peer_rate']>0 ? format_bytes($item['peer_rate'])."ps<br/>" : "").format_bytes($item['peer_total'])."</div>\n";
echo "</div>\n"; // end floatright div
echo "<div class='spacer'> </div>\n";
echo "</div>\n"; // end of $thisrow div
if ($thisrow=="row1") {$thisrow="row2";} else {$thisrow="row1";}
}
echo "<div class='bottomthin'> </div>\n";
echo "</div>\n"; // end container div
}
// Display torrent info...
if ($r_select=="torrent") {
if ($thistorrent['complete']) { $statusflags="Complete "; } else { $statusflags="Incomplete ";}
if ($thistorrent['is_hash_checked']) $statusflags.="· Hash Checked ";
if ($thistorrent['is_hash_checking']) $statusflags.="· Hash Checking ";
if ($thistorrent['is_multi_file']) $statusflags.="· Multi-file ";
if ($thistorrent['is_open']) $statusflags.="· Open ";
if ($thistorrent['is_private']) $statusflags.="· Private ";
if ($thistorrent['complete']==1) {
$statusstyle="complete";
} else {
$statusstyle="incomplete";
}
if ($thistorrent['is_active']==1) {
$statusstyle.="active";
} else {
$statusstyle.="inactive";
}
echo "<div class='container' style='width:550px'>\n";
echo "<table border=0 cellspacing=0 cellpadding=5 class='maintable' width='100%'>\n";
echo "<tr class='row2'><td class='datacol' align=right><b>Name</b></td><td><span class='torrenttitle $statusstyle'>".mb_wordwrap($thistorrent['name'],60,"<br/>\n",TRUE)."</span></td></tr>\n";
echo "<tr class='row1'><td class='datacol' align=right><b>Status</b></td><td><img src='images/".$statusstyle.".gif' width=10 height=9 alt='Status' /> ".$thistorrent['status_string']."</td></tr>\n";
echo "<tr class='row2'><td class='datacol' align=right><b>Priority</b></td><td>";
echo "<form action='control.php' method='post'>";
echo "<input type='hidden' name='hash' value='".$thistorrent['hash']."' />";
echo "<select name='set_tpriority'>\n";
echo "<option value='0' ".($thistorrent['priority']==0 ? "selected" : "").">Off </option>\n";
echo "<option value='1' ".($thistorrent['priority']==1 ? "selected" : "").">Low </option>\n";
echo "<option value='2' ".($thistorrent['priority']==2 ? "selected" : "").">Normal </option>\n";
echo "<option value='3' ".($thistorrent['priority']==3 ? "selected" : "").">High </option>\n";
echo "</select>\n";
echo "<input type='submit' value='Set' />\n";
echo "</form>\n";
echo "<tr class='row1'><td class='datacol' align=right><b>Status Flags</b></td><td>".$statusflags."</td></tr>\n";
echo "<tr class='row2'><td class='datacol' align=right><b>Message</b></td><td>".$thistorrent['message']."</td>";
echo "<tr class='row1'><td class='datacol' align=right><b>Completed Bytes</b></td><td>".format_bytes($thistorrent['completed_bytes'])."</td></tr>\n";
echo "<tr class='row2'><td class='datacol' align=right><b>Size</b></td><td>".format_bytes($thistorrent['size_bytes'])."</td></tr>\n";
echo "<tr class='row1'><td class='datacol' align=right><b>Complete</b></td><td><div class='datacollast'>".$thistorrent['percent_complete']." %<br/>";
echo percentbar(@round(($thistorrent['percent_complete']/2)))."</div>";
echo "<tr class='row2'><td class='datacol' align=right><b>Down Rate</b></td><td>".format_bytes($thistorrent['down_rate'])."</td></tr>\n";
echo "<tr class='row1'><td class='datacol' align=right><b>Down Total</b></td><td>".format_bytes($thistorrent['down_total'])."</td></tr>\n";
echo "<tr class='row2'><td class='datacol' align=right><b>Up Rate</b></td><td>".format_bytes($thistorrent['up_rate'])."</td></tr>\n";
echo "<tr class='row1'><td class='datacol' align=right><b>Up Total</b></td><td>".format_bytes($thistorrent['up_total'])."</td></tr>\n";
echo "<tr class='row2'><td class='datacol' align=right><b>Peers connected</b></td><td>".$thistorrent['peers_connected']."</td></tr>\n";
echo "<tr class='row1'><td class='datacol' align=right><b>Peers not connected</b></td><td>".$thistorrent['peers_not_connected']."</td></tr>\n";
echo "<tr class='row2'><td class='datacol' align=right><b>Peers complete</b></td><td>".$thistorrent['peers_complete']."</td></tr>\n";
echo "<tr class='row1'><td class='datacol' align=right><b>Ratio</b></td><td>".@round(($thistorrent['ratio']/1000),2)." %</td></tr>\n";
echo "</table>\n";
echo "</div>\n";
echo "<div class='bottomthin' style='width:552px;'> </div>\n";
}
// Storage info...
if ($r_select=="storage") {
echo "<div class='container' style='width:550px'>\n";
echo "<fieldset ><legend>Current Directory</legend>\n";
$seldir=$thistorrent['directory'];
$torrentdir="";
if ($thistorrent['is_multi_file']==1) {
$seldir=substr($thistorrent['directory'],0,strrpos($thistorrent['directory'],"/"));
$torrentdir=substr($thistorrent['directory'],strrpos($thistorrent['directory'],"/"));
}
$torrentdir=htmlentities($torrentdir,ENT_QUOTES,"UTF-8");
if (isset($r_dir)) $seldir=$r_dir;
echo "<p style='background-color:#ddd;padding:3px;'><span id='seldir'>".$seldir."</span><span class='gray'>".$torrentdir."</span></p>\n";
echo "<form action='control.php' method='post' name='directory' onSubmit=\"document.directory.newdir.value=document.getElementById('seldir').innerHTML;\">\n";
if ($thistorrent['is_active']==1) {
echo "<p><input type='submit' name='setdir' value='Set directory' disabled=1> <i>Torrent must be stopped before changing directory.</i></p>\n";
} else {
echo "<input type='hidden' name='hash' value='".$thistorrent['hash']."'>\n";
echo "<input type='hidden' name='newdir' value=''>\n";
echo "<input type='submit' name='setdir' value='Set directory'>\n";
}
echo "</fieldset>\n";
echo "</form>\n";
echo "<iframe frameborder=0 src='dirbrowser.php?dir=".urlencode($seldir)."&hilitedir=".urlencode($torrentdir)."' width=100% height=300px>iFrame</iframe>";
echo "<br> </div>"; // end container div
echo "<div class='bottomthin' style='width:552px;'> </div>\n";
}
// Debug info
if ($r_select=="debug") {
echo "<pre class='medtext'>";
echo "<h2>Torrent</h2>";
echo nl2br(print_r($thistorrent));
echo "<h2>Files</h2>";
echo nl2br(print_r(get_file_list($r_hash)));
echo "<h2>Peers</h2>";
echo nl2br(print_r(get_peer_list($r_hash)));
echo "<h2>Tracker</h2>";
echo nl2br(print_r(get_tracker_list($r_hash)));
echo "</pre>";
}
?>
</div>
</body>
</html>