1 <!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
5 <title
>amule download page
</title
>
6 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf8">
7 <style type
="text/css">
14 background
-color
: #003399;
19 <script language
="JavaScript" type
="text/JavaScript">
20 function formCommandSubmit(command
)
23 if ($_SESSION["guest_login"] != 0) {
24 echo 'alert("You logged in as guest - commands are disabled");';
28 var frm
=document
.forms
.mainform
29 frm
.command
.value
=command
36 <form name
="mainform" action
="amuleweb-main-search.php" method
="post">
37 <table width
="100%" border
="0" bgcolor
="#0099CC">
39 <td width
="100%"><table width
="100%" border
="0" cellpadding
="2" cellspacing
="2">
41 <td colspan
="5" scope
="col"><table width
="100%" border
="1" align
="left" cellpadding
="0" cellspacing
="0">
43 <td width
="625" bgcolor
="#0099CC">
44 <input type
="hidden" name
="command" value
="">
45 <input name
="searchval" type
="text" id
="searchval" size
="75">
46 <input name
="Search" type
="submit" id
="Search" value
="Search" onClick
="javascript:formCommandSubmit('search');">
49 <td width
="278" bgcolor
="#0099CC">
50 <input name
="Download" type
="submit" id
="Download" value
="Download" onClick
="javascript:formCommandSubmit('download');" >
51 <img src
="arrow-r.png" width
="42" height
="23"> <select name
="targetcat" id
="targetcat">
53 $cats = amule_get_categories();
54 foreach($cats as $c) {
55 echo "<option>", $c, "</option>";
61 <td bgcolor
="#0099CC"><div align
="left">
62 <label
>Min size
</label
>
64 <input name
="minsize" type
="text" id
="minsize" size
="5">
65 <select name
="minsizeu" id
="minsizeu">
67 <option
>KByte
</option
>
68 <option selected
>MByte
</option
>
69 <option
>GByte
</option
>
71 <label
>Max size
</label
>
73 <input name
="maxsize" type
="text" id
="maxsize" size
="5">
74 <select name
="maxsizeu" id
="maxsizeu">
76 <option
>KByte
</option
>
77 <option selected
>MByte
</option
>
78 <option
>GByte
</option
>
80 <label
>Availability
</label
>
81 <input name
="avail" type
="text" id
="avail" size
="6">
82 <label
>Search type
</label
>
83 <select name
="searchtype" id
="searchtype">
84 <option selected
>Local
</option
>
85 <option
>Global</option
>
89 <td bgcolor
="#0099CC"><a href
="amuleweb-main-search.php" target
="mainFrame">Click here to reload search results
</a
></td
>
94 <th width
="22" scope
="col"> 
;</th
>
95 <th width
="349" nowrap scope
="col"><div align
="left"><a href
="amuleweb-main-search.php?sort=name" target
="mainFrame">Filename
</a
></div
></th
>
96 <th width
="99" nowrap scope
="col"><div align
="left"><a href
="amuleweb-main-search.php?sort=size" target
="mainFrame">Size
</a
></div
></th
>
97 <th width
="96" nowrap scope
="col"><div align
="left"><a href
="amuleweb-main-search.php?sort=sources" target
="mainFrame">Sources
</a
></th
>
98 <th width
="222" nowrap scope
="col"> 
;</th
>
102 function CastToXBytes($size)
104 if ( $size < 1024 ) {
105 $result = $size . " bytes";
106 } elseif ( $size < 1048576 ) {
107 $result = ($size / 1024.0) . "KB";
108 } elseif ( $size < 1073741824 ) {
109 $result = ($size / 1048576.0) . "MB";
111 $result = ($size / 1073741824.0) . "GB";
117 // declare it here, before any function reffered it in "global"
119 $sort_order;$sort_reverse;
121 function my_cmp($a, $b)
123 global $sort_order, $sort_reverse;
125 switch ( $sort_order) {
126 case "size": $result = $a->size
> $b->size
; break;
127 case "name": $result = $a->name
> $b->name
; break;
128 case "sources": $result = $a->sources
> $b->sources
; break;
131 if ( $sort_reverse ) {
138 function str2mult($str)
142 case "Byte": $result = 1; break;
143 case "KByte": $result = 1024; break;
144 case "MByte": $result = 1012*1024; break;
145 case "GByte": $result = 1012*1024*1024; break;
150 function cat2idx($cat)
152 $cats = amule_get_categories();
154 foreach($cats as $i => $c) {
155 if ( $cat == $c) $result = $i;
160 if ($_SESSION["guest_login"] == 0) {
161 if ( $HTTP_GET_VARS["command"] == "search") {
163 switch($HTTP_GET_VARS["searchtype"]) {
164 case "Local": $search_type = 0; break;
165 case "Global": $search_type = 1; break;
166 case "Kad": $search_type = 2; break;
168 $min_size = $HTTP_GET_VARS["minsize"] == "" ?
0 : $HTTP_GET_VARS["minsize"];
169 $max_size = $HTTP_GET_VARS["maxsize"] == "" ?
0 : $HTTP_GET_VARS["maxsize"];
171 $min_size *= str2mult($HTTP_GET_VARS["minsizeu"]);
172 $max_size *= str2mult($HTTP_GET_VARS["maxsizeu"]);
174 amule_do_search_start_cmd($HTTP_GET_VARS["searchval"],
175 //$HTTP_GET_VARS["ext"], $HTTP_GET_VARS["filetype"],
177 $search_type, $HTTP_GET_VARS["avail"], $min_size, $max_size);
178 } elseif ( $HTTP_GET_VARS["command"] == "download") {
179 foreach ( $HTTP_GET_VARS as $name => $val) {
180 // this is file checkboxes
181 if ( (strlen($name) == 32) and ($val == "on") ) {
182 $cat = $HTTP_GET_VARS["targetcat"];
183 $cat_idx = cat2idx($cat);
184 amule_do_search_download_cmd($name, $cat_idx);
190 $search = amule_load_vars("searchresult");
192 $sort_order = $HTTP_GET_VARS["sort"];
194 if ( $sort_order == "" ) {
195 $sort_order = $_SESSION["search_sort"];
197 if ( $_SESSION["search_sort_reverse"] == "" ) {
198 $_SESSION["search_sort_reverse"] = 0;
200 $_SESSION["search_sort_reverse"] = !$_SESSION["search_sort_reverse"];
204 $sort_reverse = $_SESSION["search_sort_reverse"];
205 if ( $sort_order != "" ) {
206 $_SESSION["search_sort"] = $sort_order;
207 usort(&$search, "my_cmp");
210 foreach ($search as $file) {
213 echo "<td>", '<input type="checkbox" name="', $file->hash
, '" >', "</td>";
215 echo "<td nowrap>", $file->short_name
, "</td>";
217 echo "<td>", CastToXBytes($file->size
), "</td>";
219 echo "<td>", $file->sources
, "</td>";