Upstream tarball 20080304
[amule.git] / src / webserver / default / search.php
blobc228835c0e6f3179b7e69dc852ea1b44a15cb3a7
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
5 <META HTTP-EQUIV="PRAGMAS" CONTENT="NO-CACHE">
6 <?php
7 echo "<title>aMule " , amule_get_version(), " - Web Control Panel</title>";
8 ?>
9 <style type="text/css">
10 img
12 border : 0px;
14 a, a:active, a:link, a:visited
16 color: white;
18 .down-header, .down-header-left, .down-header-right,
19 .down-line, .down-line-good, .down-line-left, .down-line-good-left,
20 .down-line-right, .down-line-good-right,
21 .up-header, .up-header-left, .up-line, .up-line-left,
22 .server-header, .server-header-left, .server-line, .server-line-left,
23 .shared-header, .shared-header-left, .shared-line, .shared-line-changed,
24 .shared-line-left, .shared-line-left-changed,
25 .header, .smallheader, .commontext,
26 .upqueue-header, .upqueue-line, .upqueue-line-left,
27 .websearch-header, .websearch-line, .addserver-header, .addserver-line
29 font-family : Tahoma;
30 font-size : 8pt;
32 .tabs
34 font-family : Tahoma;
35 font-size : 10pt;
36 background-color : #3399FF;
38 .down-header, .down-line, .down-line-good, .up-header, .up-line,
39 .server-header, .server-line, .shared-header, .shared-line, .shared-line-changed,
40 .upqueue-header, .upqueue-line,
41 .websearch-header, .websearch-line, .addserver-header, .addserver-line
43 text-align : center;
45 .down-header-left, .down-line-left, .down-line-good-left,
46 .server-header-left, .server-line-left, .shared-header-left,
47 .up-header-left, .up-line-left, .shared-line-left, .shared-line-left-changed, .upqueue-line-left
49 text-align : left;
51 .down-line-right, .down-line-good-right, .down-header-right
53 text-align : right;
55 .down-header, .down-header-left, .down-header-right,
56 .up-header, .up-header-left, .server-header, .server-header-left,
57 .shared-header, .shared-header-left, .upqueue-header,
58 .websearch-header, .addserver-header
60 background-color : #0066CC;
62 .header
64 background-color : #0046AC;
66 .smallheader
68 background-color : #003399;
69 color : #FFFFFF;
71 .commontext
73 background-color : #FFFFFF;
74 color : #000000;
76 .down-line, .down-line-good, .down-line-left, .down-line-good-left,
77 .down-line-right, .down-line-good-right,
78 .up-line, .up-line-left, .server-line, .server-line-left,
79 .shared-line, .shared-line-changed, .shared-line-left, .shared-line-left-changed,
80 .upqueue-line, .upqueue-line-left,
81 .websearch-line, .addserver-line
83 background-color : #3399FF;
85 .down-line-good, .down-line-good-left, .down-line-good-right, .shared-line-changed, .shared-line-left-changed
87 color : #F0F000;
89 .percent_table
91 border:0px solid #000000;
92 border-collapse: collapse;
94 .message
96 font-size: 10pt;
97 font-weight: bold;
98 color: #FF0000;
100 .dinput
102 border-width: 1px;
103 border-color: black;
105 </style>
106 </head>
107 <body bgcolor="#FBDE9C" text=white link="#3399FF" vlink="#3399FF" alink="#3399FF" marginwidth=0 marginheight=0 topmargin=0 leftmargin=0 style="margin:0px">
108 <table border=0 width="100%" align=center cellpadding=4 cellspacing=0>
109 <tr>
110 <td class="tabs" align="left" colspan="2">
112 <table border="0" cellpadding="4" cellspacing="0">
113 <tr>
114 <td class="tabs" align="center">
115 &nbsp;<a href="http://www.amule.org" target="_blank"><img src="emule.gif"></a>
116 <font face="Tahoma" style="font-size:13pt;" color="#000000">aMule<br>Web Control Panel</font>
117 </td>
118 <td class="tabs" align="center" width="30">&nbsp; </td>
120 <td align="center" class="tabs" width="95">
121 <a href="servers.php">
122 <img src="cp_servers.gif"><br>
123 Server list
124 </a>
125 </td>
126 <td align="center" class="tabs" width="95">
127 <a href="downloads.php">
128 <img src="cp_download.gif"><br>
130 Transfer
131 </a>
132 </td>
133 <td align="center" class="tabs" width="95">
134 <a href="search.php">
135 <img src="cp_search.gif"><br>
136 Search
137 </a>
138 </td>
139 <td align="center" class="tabs" width="95">
141 <a href="shared.php">
142 <img src="cp_shared.gif"><br>
143 Shared Files
144 </a>
145 <td align="center" class="tabs" width="110">
146 <a href="stat_tree.php">
147 <img src="cp_stats.gif"><br>
148 Statistics</a>
149 <font color="#000000">|</font>
151 <a href="stat_graphs.php">Graphs</a>
152 </td>
153 </td>
154 <td align="center" class="tabs" width="95">
155 <a href="preferences.php">
156 <img src="cp_settings.gif"><br>
157 Preferences
158 </a>
159 </td>
161 <td class="tabs" align="center" width="30">&nbsp;</td>
162 <td align="left" class="tabs" width="95">
163 <img src="log.gif"> <a href="index.php?serverinfo=1">Serverinfo</a><br>
164 <img src="log.gif"> <a href="index.php?log=1">Log</a>
165 </td>
166 </tr>
167 </table>
169 </td>
170 </tr>
171 <tr>
172 <td style="background-color: #000000; height: 1px" colspan="2">
173 </td>
174 </tr>
175 <tr>
176 <td class="tabs">
177 &nbsp;&nbsp;<b>Connection:</b>
178 <?php
179 function CastToXBytes($size)
181 if ( $size < 1024 ) {
182 $result = $size . " bytes";
183 } elseif ( $size < 1048576 ) {
184 $result = ($size / 1024.0) . "KB";
185 } elseif ( $size < 1073741824 ) {
186 $result = ($size / 1048576.0) . "MB";
187 } else {
188 $result = ($size / 1073741824.0) . "GB";
190 return $result;
193 $stats = amule_get_stats();
194 if ( $stats["kad_connected"] == 1 ) {
195 echo "Connected";
196 if ( $stats["kad_firewalled"] == 1 ) {
197 echo " to KAD (firewalled), ";
198 } else {
199 echo " to KAD, ";
201 } else {
202 echo "Not connected to KAD, ";
204 if ( $stats["id"] == 0 ) {
205 echo "not connected to ED2K";
206 } elseif ( $stats["id"] == 0xffffffff ) {
207 echo "connecting to ED2k";
208 } else {
209 echo "connected with ", (($stats["id"] < 16777216) ? "low" : "high"), " ID to ",
210 $stats["serv_name"], " ", $stats["serv_addr"];
212 echo '<br>&nbsp;&nbsp;<b>Speed:</b> Up: ', CastToXBytes($stats["speed_up"]), 'ps',
213 ' | Down: ', CastToXBytes($stats["speed_down"]), 'ps',
214 '<small> (Limits: ', CastToXBytes($stats["speed_limit_up"]), 'ps/',
215 CastToXBytes($stats["speed_limit_down"]), 'ps)</small>&nbsp;';
218 <font color=black>
220 <script type="text/javascript" language="javascript">
221 var d = new Date();
222 s = "[ " + d.getDate() + "/" + (d.getMonth() + 1) + "/" + d.getFullYear() + " " + d.getHours() + ":" + (d.getMinutes() < 10 ? "0" : "") + d.getMinutes() + ":" + (d.getSeconds() < 10 ? "0" : "") + d.getSeconds() + " ]";
223 document.write(s);
224 </script>
225 </font>
226 </td>
227 <td align=right class=tabs>
228 <form>
229 <input type="button" value="ed2k://Download" onClick='self.location.href="index.php?links=1"'>
230 <input type="button" value="Logout" onClick='self.location.href="login.php"'>
231 </form>
232 </td>
233 </tr>
234 </table>
236 &nbsp;
237 <p align=center><div class="message"></div></p><br>
239 <table border=0 align=center cellpadding=4 cellspacing=0 width="85%">
240 <tr>
241 <td valign=middle class="websearch-header"><b><font face=Tahoma style="font-size:10pt;">Search Results</font></b>&nbsp;&nbsp;(<a align="right" href="javascript:self.location.href='search.php'"><font face=Tahoma style="font-size:8pt;">Refetch Results</font></a>)</td>
242 </tr>
244 <tr>
245 <td valign=middle class="websearch-line">
247 <form action="" method="GET">
248 <table border=0 align=center cellpadding=4 cellspacing=0>
249 <input type="hidden" name=cmd value="download">
250 <tr>
251 <td class="websearch-line"><b><font face=Tahoma style="font-size:8pt;"><a href="search.php?sort=name">File Name</a></font></b></td>
252 <td class="websearch-line" width=50><b><font face=Tahoma style="font-size:8pt;"><a href="search.php?sort=size">Size</a></font></b></td>
253 <td class="websearch-line"><b><font face=Tahoma style="font-size:8pt;"><a href="search.php?sort=sources">Sources</a></b></td>
254 <td class="websearch-line" width=100><b><font face=Tahoma style="font-size:8pt;">Download</font></b></td>
255 </tr>
257 <?php
258 function CastToXBytes($size)
260 if ( $size < 1024 ) {
261 $result = $size . " bytes";
262 } elseif ( $size < 1048576 ) {
263 $result = ($size / 1024.0) . "KB";
264 } elseif ( $size < 1073741824 ) {
265 $result = ($size / 1048576.0) . "MB";
266 } else {
267 $result = ($size / 1073741824.0) . "GB";
269 return $result;
271 function cat2idx($cat)
273 $cats = amule_get_categories();
274 $result = 0;
275 foreach($cats as $i => $c) {
276 if ( $cat == $c) $result = $i;
278 return $result;
282 // declare it here, before any function reffered it in "global"
284 $sort_order;$sort_reverse;
286 function my_cmp($a, $b)
288 global $sort_order, $sort_reverse;
290 switch ( $sort_order) {
291 case "size": $result = $a->size > $b->size; break;
292 case "name": $result = $a->name > $b->name; break;
293 case "sources": $result = $a->sources > $b->sources; break;
296 if ( $sort_reverse ) {
297 $result = !$result;
300 return $result;
303 if ($_SESSION["guest_login"] == 0) {
304 if ( $HTTP_GET_VARS["cmd"] == "search") {
306 $search_type = -1;
307 switch($HTTP_GET_VARS["method"]) {
308 case "server": $search_type = 0; break;
309 case "global": $search_type = 1; break;
310 case "kad": $search_type = 2; break;
313 $min_size = $HTTP_GET_VARS["min"] == "" ? 0 : $HTTP_GET_VARS["min"];
314 $max_size = $HTTP_GET_VARS["max"] == "" ? 0 : $HTTP_GET_VARS["max"];
316 $min_size *= 1024*1024;
317 $max_size *= 1024*1024;
319 amule_do_search_start_cmd($HTTP_GET_VARS["tosearch"],
320 $HTTP_GET_VARS["ext"], $HTTP_GET_VARS["type"],
321 $search_type, $HTTP_GET_VARS["avail"], $min_size, $max_size);
322 } elseif ( $HTTP_GET_VARS["cmd"] == "download") {
323 foreach ( $HTTP_GET_VARS as $name => $val) {
324 // this is file checkboxes
325 if ( (strlen($name) == 32) and ($val == "on") ) {
326 $cat = $HTTP_GET_VARS["cat"];
327 $cat_idx = cat2idx($cat);
328 amule_do_search_download_cmd($name, $cat_idx);
331 } else {
332 // wrong command come
333 //var_dump($HTTP_GET_VARS);
337 $search = amule_load_vars("searchresult");
339 $sort_order = $HTTP_GET_VARS["sort"];
341 if ( $sort_order == "" ) {
342 $sort_order = $_SESSION["search_sort"];
343 } else {
344 if ( $_SESSION["search_sort_reverse"] == "" ) {
345 $_SESSION["search_sort_reverse"] = 0;
346 } else {
347 $_SESSION["search_sort_reverse"] = !$_SESSION["search_sort_reverse"];
351 $sort_reverse = $_SESSION["search_sort_reverse"];
352 if ( $sort_order != "" ) {
353 $_SESSION["search_sort"] = $sort_order;
354 usort(&$search, "my_cmp");
357 foreach ($search as $file) {
358 echo '<tr><td align="left"><font face=Tahoma style="font-size:8pt;">', $file->name,
359 '</font></td><td class="websearch-line"><font face=Tahoma style="font-size:8pt;">', CastToXBytes($file->size),
360 '</font></td><td class="websearch-line"><font face=Tahoma style="font-size:8pt;">', $file->sources,
361 '</font></td><td class="websearch-line"><input type="checkbox" name="', $file->hash,
362 '"></td></tr>';
367 </table>
369 <input type="submit" value="Download">
370 <img src="arrow_right.gif" align="absmiddle">
371 <form>
372 <select name="cat" size="1">
373 <?php
374 $cats = amule_get_categories();
375 foreach($cats as $c) {
376 echo "<option>", $c, "</option>";
379 </select>
380 </form>
382 </form>
383 <br>
384 <br>
385 &nbsp;
386 </table>
387 <br>
389 <form action="" method="GET">
390 <table border=0 align=center cellpadding=4 cellspacing=0 width="250">
391 <tr>
392 <td valign=middle class="websearch-header"><b><font face=Tahoma style="font-size:10pt;">Search</font></b></td>
393 </tr>
394 <tr>
395 <td valign=middle class="websearch-line">
396 <table>
397 <tr><td class=tabs width=150>Name</td><td><input name="tosearch" type="text" size="40"></td></tr>
398 <tr><td class=tabs>Type</td>
399 <td>
400 <select name="type">
401 <option value=""></option>
402 <option value="Archives">Archive</option>
403 <option value="Audio">Audio</option>
404 <option value="CD-Images">CD-Images</option>
405 <option value="Pictures">Pictures</option>
406 <option value="Programs">Programs</option>
407 <option value="Texts">Texts</option>
408 <option value="Videos">Video</option>
409 </select>
410 </td></tr>
411 <tr><td class=tabs>Min Size (MB)</td><td><input name="min" type="text" size="10"></td></tr>
412 <tr><td class=tabs>Max Size (MB)</td><td><input name="max" type="text" size="10"></td></tr>
413 <tr><td class=tabs>Min Availability</td><td><input name="avail" type="text" size="10"></td></tr>
414 <tr><td class=tabs>Extension</td><td><input name="ext" type="text" size="10"></td></tr>
415 <tr><td class=tabs>Method</td><td><input value="server" type="radio" name="method" checked>Server</td></tr>
416 <tr><td class=tabs></td><td><input value="global" type="radio" name="method">Global Search</td></tr>
417 <tr><td class=tabs></td><td><input value="kad" type="radio" name="method">Kad Search</td></tr>
418 </table>
419 <br>
420 <input type="hidden" name=cmd value="search">
421 <input type="submit" value="Search">
422 <br>
423 &nbsp;
424 </td>
425 </tr>
426 </table>
429 </body>
430 </html>