36 |
open CommonTypes |
open CommonTypes |
37 |
open Int64ops |
open Int64ops |
38 |
|
|
39 |
|
|
40 |
(* ripped from gui_downloads *) |
(* ripped from gui_downloads *) |
41 |
|
|
42 |
let calc_file_eta f = |
let calc_file_eta f = |
60 |
else 0. |
else 0. |
61 |
else rate |
else rate |
62 |
in |
in |
63 |
let eta = |
let eta = |
64 |
if rate < 11. |
if rate < 11. |
65 |
then hundays |
then hundays |
66 |
else missing /. rate |
else missing /. rate |
67 |
in |
in |
68 |
int_of_float eta |
int_of_float eta |
69 |
end |
end |
70 |
) |
) |
71 |
|
|
72 |
|
|
73 |
let file_availability f = |
let file_availability f = |
74 |
match f.file_availability with |
match f.file_availability with |
75 |
(_,avail) :: _ -> |
(_,avail) :: _ -> |
76 |
let rec loop i p n = |
let rec loop i p n = |
77 |
if i < 0 |
if i < 0 |
78 |
then |
then |
79 |
if n < 0.0001 |
if n < 0.0001 |
80 |
then 0.0 |
then 0.0 |
81 |
else (p /. n *. 100.0) |
else (p /. n *. 100.0) |
86 |
then loop (i - 1) (p +. 1.0) (n +. 1.0) |
then loop (i - 1) (p +. 1.0) (n +. 1.0) |
87 |
else loop (i - 1) p (n +. 1.0) |
else loop (i - 1) p (n +. 1.0) |
88 |
else loop (i - 1) p n |
else loop (i - 1) p n |
89 |
in |
in |
90 |
loop ((String.length avail) - 1) 0.0 0.0 |
loop ((String.length avail) - 1) 0.0 0.0 |
91 |
| _ -> 0.0 |
| _ -> 0.0 |
92 |
|
|
93 |
let string_availability s = |
let string_availability s = |
94 |
match s with |
match s with |
95 |
(_,s) :: _ -> |
(_,s) :: _ -> |
96 |
|
|
97 |
let len = String.length s in |
let len = String.length s in |
98 |
let p = ref 0 in |
let p = ref 0 in |
99 |
for i = 0 to len - 1 do |
for i = 0 to len - 1 do |
101 |
incr p |
incr p |
102 |
end |
end |
103 |
done; |
done; |
104 |
if len = 0 then 0.0 else |
if len = 0 then 0.0 else |
105 |
(float_of_int !p /. float_of_int len *. 100.) |
(float_of_int !p /. float_of_int len *. 100.) |
106 |
| _ -> 0.0 |
| _ -> 0.0 |
107 |
|
|
108 |
let get_file_availability f = |
let get_file_availability f = |
109 |
if !!html_mods_use_relative_availability |
if !!html_mods_use_relative_availability |
110 |
then file_availability f |
then file_availability f |
111 |
else string_availability f.file_availability |
else string_availability f.file_availability |
112 |
|
|
113 |
|
|
114 |
(* WARNING: these computations are much more expensive as they seem. |
(* WARNING: these computations are much more expensive as they seem. |
115 |
We use the ShortLazy to avoid recomputing the result too many times, |
We use the ShortLazy to avoid recomputing the result too many times, |
116 |
in particular when sorting the files depending on their number of sources... |
in particular when sorting the files depending on their number of sources... |
117 |
|
|
118 |
2004/06/18: file.file_all_sources is used when not zero, and in this case, |
2004/06/18: file.file_all_sources is used when not zero, and in this case, |
119 |
also file.file_active_sources. |
also file.file_active_sources. |
120 |
*) |
*) |
121 |
|
|
122 |
let number_of_sources gf = |
let number_of_sources gf = |
123 |
List.length (file_all_sources (file_find gf.file_num)) |
List.length (file_all_sources (file_find gf.file_num)) |
124 |
|
|
125 |
let number_of_sources gf = |
let number_of_sources gf = |
128 |
else |
else |
129 |
ShortLazy.compute ("number_of_sources", gf.file_num, 0) |
ShortLazy.compute ("number_of_sources", gf.file_num, 0) |
130 |
number_of_sources gf |
number_of_sources gf |
131 |
|
|
132 |
let number_of_active_sources gf = |
let number_of_active_sources gf = |
133 |
let nasrcs = ref 0 in |
let nasrcs = ref 0 in |
134 |
List.iter (fun fsrc -> |
List.iter (fun fsrc -> |
139 |
!nasrcs |
!nasrcs |
140 |
|
|
141 |
let number_of_active_sources gf = |
let number_of_active_sources gf = |
142 |
if gf.file_all_sources > 0 then |
if gf.file_all_sources > 0 then |
143 |
gf.file_active_sources |
gf.file_active_sources |
144 |
else begin |
else begin |
145 |
ShortLazy.compute ("number_of_active_sources", gf.file_num, 0) |
ShortLazy.compute ("number_of_active_sources", gf.file_num, 0) |
146 |
number_of_active_sources gf |
number_of_active_sources gf |
147 |
end |
end |
148 |
|
|
149 |
let net_name gf = |
let net_name gf = |
150 |
let n = network_find_by_num gf.file_network in |
let n = network_find_by_num gf.file_network in |
151 |
n.network_name |
n.network_name |
152 |
|
|
153 |
let short_net_name gf = |
let short_net_name gf = |
154 |
let nn = net_name gf in |
let nn = net_name gf in |
155 |
match nn with |
match nn with |
156 |
| "OpenNapster" -> "N" |
| "OpenNapster" -> "N" |
157 |
| "Direct Connect" -> "C" |
| "Direct Connect" -> "C" |
158 |
| "FileTP" -> "T" |
| "FileTP" -> "T" |
159 |
| _ -> String.sub nn 0 1 |
| _ -> String.sub nn 0 1 |
160 |
|
|
161 |
|
|
162 |
module Html = struct |
module Html = struct |
163 |
let begin_td buf = Printf.bprintf buf "\\<td\\>" |
let begin_td buf = Printf.bprintf buf "\\<td\\>" |
164 |
let begin_td_option buf option= Printf.bprintf buf "\\<td %s\\>" option |
let begin_td_option buf option= Printf.bprintf buf "\\<td %s\\>" option |
168 |
let end_table buf = Printf.bprintf buf "\\</table\\>" |
let end_table buf = Printf.bprintf buf "\\</table\\>" |
169 |
let begin_tr buf = Printf.bprintf buf "\\<tr\\>" |
let begin_tr buf = Printf.bprintf buf "\\<tr\\>" |
170 |
let end_tr buf = Printf.bprintf buf "\\</tr\\>" |
let end_tr buf = Printf.bprintf buf "\\</tr\\>" |
171 |
|
|
172 |
let button buf value onclick = |
let button buf value onclick = |
173 |
Printf.bprintf buf " |
Printf.bprintf buf " |
174 |
\\<input type=\\\"button\\\" value=\\\"%s\\\" onclick=\\\"%s\\\"\\>" |
\\<input type=\\\"button\\\" value=\\\"%s\\\" onclick=\\\"%s\\\"\\>" |
175 |
value onclick |
value onclick |
176 |
end |
end |
177 |
|
|
178 |
let initialization_completed = ref false |
let initialization_completed = ref false |
179 |
|
|
180 |
let save_config () = |
let save_config () = |
181 |
(try Unix32.flush () with e -> |
(try Unix32.flush () with e -> |
182 |
Printf2.lprintf "Exception %s while flushing\n" (Printexc2.to_string e) |
Printf2.lprintf "Exception %s while flushing\n" (Printexc2.to_string e) |
183 |
); |
); |
184 |
if !initialization_completed then ( |
if !initialization_completed then ( |
186 |
Options.save_with_help_private users_ini; |
Options.save_with_help_private users_ini; |
187 |
CommonComplexOptions.save (); |
CommonComplexOptions.save (); |
188 |
CommonUploads.save (); |
CommonUploads.save (); |
189 |
networks_iter_all (fun r -> |
networks_iter_all (fun r -> |
190 |
List.iter (fun opfile -> |
List.iter (fun opfile -> |
191 |
Options.save_with_help opfile |
Options.save_with_help opfile |
192 |
) r.network_config_file); |
) r.network_config_file); |
193 |
) else ( |
) else ( |
194 |
Printf2.lprintf "Initialization not completed, bypassing state saving\n" |
Printf2.lprintf "Initialization not completed, bypassing state saving\n" |
195 |
); |
); |
196 |
() |
() |
197 |
|
|
198 |
let age_to_day date = |
let age_to_day date = |
199 |
(last_time () - date) / Date.day_in_secs |
(last_time () - date) / Date.day_in_secs |
200 |
|
|
201 |
|
|
202 |
let percent file = |
let percent file = |
203 |
let downloaded = Int64.to_float file.file_downloaded in |
let downloaded = Int64.to_float file.file_downloaded in |
204 |
let size = Int64.to_float file.file_size in |
let size = Int64.to_float file.file_size in |
205 |
if size < 1.0 |
if size < 1.0 |
209 |
let short_name file = |
let short_name file = |
210 |
shorten file.file_name !!max_name_len |
shorten file.file_name !!max_name_len |
211 |
|
|
212 |
type table_align = |
type table_align = |
213 |
Align_Left |
Align_Left |
214 |
| Align_Right |
| Align_Right |
215 |
| Align_Center |
| Align_Center |
222 |
Align_Center -> |
Align_Center -> |
223 |
let left = diff / 2 in |
let left = diff / 2 in |
224 |
let right = diff - left in |
let right = diff - left in |
225 |
Printf.bprintf buf "%s%s%s" |
Printf.bprintf buf "%s%s%s" |
226 |
(String.make left ' ') s (String.make right ' ') |
(String.make left ' ') s (String.make right ' ') |
227 |
| Align_Right -> |
| Align_Right -> |
228 |
Printf.bprintf buf "%s%s" (String.make diff ' ') s |
Printf.bprintf buf "%s%s" (String.make diff ' ') s |
229 |
| Align_Left -> |
| Align_Left -> |
230 |
Printf.bprintf buf "%s%s" s (String.make diff ' ') |
Printf.bprintf buf "%s%s" s (String.make diff ' ') |
231 |
|
|
232 |
let print_table_text buf alignments titles lines = |
let print_table_text buf alignments titles lines = |
233 |
let max_cols = ref (max (Array.length titles) (Array.length alignments)) in |
let max_cols = ref (max (Array.length titles) (Array.length alignments)) in |
234 |
List.iter (fun line -> |
List.iter (fun line -> |
239 |
let cols = Array.create ncols 0 in |
let cols = Array.create ncols 0 in |
240 |
List.iter (fun line -> |
List.iter (fun line -> |
241 |
let len = Array.length line in |
let len = Array.length line in |
242 |
for i = 0 to len-1 do |
for i = 0 to len-1 do |
243 |
let slen = String.length line.(i) in |
let slen = String.length line.(i) in |
244 |
if cols.(i) < slen then cols.(i) <- slen |
if cols.(i) < slen then cols.(i) <- slen |
245 |
done; |
done; |
246 |
) (titles :: lines); |
) (titles :: lines); |
247 |
Array.iteri (fun i s -> |
Array.iteri (fun i s -> |
248 |
add buf s Align_Center cols.(i); |
add buf s Align_Center cols.(i); |
249 |
Buffer.add_string buf col_sep; |
Buffer.add_string buf col_sep; |
250 |
) titles; |
) titles; |
251 |
Buffer.add_char buf '\n'; |
Buffer.add_char buf '\n'; |
252 |
let aligns = Array.create ncols Align_Center in |
let aligns = Array.create ncols Align_Center in |
253 |
Array.iteri (fun i al -> aligns.(i) <- al) alignments; |
Array.iteri (fun i al -> aligns.(i) <- al) alignments; |
254 |
List.iter (fun line -> |
List.iter (fun line -> |
255 |
let len = Array.length line in |
let len = Array.length line in |
256 |
Array.iteri (fun i s -> |
Array.iteri (fun i s -> |
257 |
add buf s aligns.(i) cols.(i); |
add buf s aligns.(i) cols.(i); |
258 |
if i+1 < len then Buffer.add_string buf col_sep; |
if i+1 < len then Buffer.add_string buf col_sep; |
259 |
) line; |
) line; |
260 |
Buffer.add_char buf '\n'; |
Buffer.add_char buf '\n'; |
261 |
) lines |
) lines |
262 |
|
|
263 |
|
|
264 |
let print_table_html_mods buf lines = |
let print_table_html_mods buf lines = |
265 |
|
|
266 |
let counter = ref 0 in |
let counter = ref 0 in |
267 |
|
|
268 |
List.iter (fun line -> |
List.iter (fun line -> |
269 |
if (!counter mod 2 == 0) then Printf.bprintf buf "\\<tr class=dl-1" |
if (!counter mod 2 == 0) then Printf.bprintf buf "\\<tr class=dl-1" |
270 |
else Printf.bprintf buf "\\<tr class=dl-2"; |
else Printf.bprintf buf "\\<tr class=dl-2"; |
271 |
incr counter; |
incr counter; |
272 |
|
|
273 |
Array.iter (fun data -> |
Array.iter (fun data -> |
274 |
Printf.bprintf buf "%s" data; |
Printf.bprintf buf "%s" data; |
275 |
) line; |
) line; |
280 |
Html.end_tr buf; |
Html.end_tr buf; |
281 |
Html.end_table buf; |
Html.end_table buf; |
282 |
Printf.bprintf buf "\\</div\\>" |
Printf.bprintf buf "\\</div\\>" |
|
|
|
283 |
|
|
284 |
|
|
285 |
|
|
286 |
let print_table_html spacing buf aligns titles lines = |
let print_table_html spacing buf aligns titles lines = |
287 |
Html.begin_table buf; |
Html.begin_table buf; |
288 |
|
|
289 |
Html.begin_tr buf; |
Html.begin_tr buf; |
290 |
Array.iter (fun title -> |
Array.iter (fun title -> |
291 |
Printf.bprintf buf "\\<td align=center\\>%s\\</td\\>" title; |
Printf.bprintf buf "\\<td align=center\\>%s\\</td\\>" title; |
293 |
) titles; |
) titles; |
294 |
let naligns = Array.length aligns in |
let naligns = Array.length aligns in |
295 |
Html.end_tr buf; |
Html.end_tr buf; |
296 |
|
|
297 |
List.iter (fun line -> |
List.iter (fun line -> |
298 |
Html.begin_tr buf; |
Html.begin_tr buf; |
299 |
Array.iteri (fun i title -> |
Array.iteri (fun i title -> |
300 |
Printf.bprintf buf "\\<td%s nowrap\\>%s\\</td\\>" |
Printf.bprintf buf "\\<td%s nowrap\\>%s\\</td\\>" |
301 |
(if i >= naligns then "" else |
(if i >= naligns then "" else |
302 |
match aligns.(i) with |
match aligns.(i) with |
303 |
Align_Center -> " align=center" |
Align_Center -> " align=center" |
320 |
match file.file_state with |
match file.file_state with |
321 |
| FilePaused | FileQueued -> true |
| FilePaused | FileQueued -> true |
322 |
| _ -> false |
| _ -> false |
323 |
|
|
324 |
|
|
325 |
let print_file_html_form buf files = |
let print_file_html_form buf files = |
326 |
|
|
327 |
|
|
328 |
Printf.bprintf buf " |
Printf.bprintf buf " |
329 |
\\<script language=JavaScript\\>\\<!-- |
\\<script language=JavaScript\\>\\<!-- |
330 |
function pauseAll(x){for(i=0;i\\<document.selectForm.elements.length;i++){var j=document.selectForm.elements[i];if (j.name==\\\"pause\\\") {j.checked=x;}}} |
function pauseAll(x){for(i=0;i\\<document.selectForm.elements.length;i++){var j=document.selectForm.elements[i];if (j.name==\\\"pause\\\") {j.checked=x;}}} |
332 |
function cancelAll(x){for(i=0;i\\<document.selectForm.elements.length;i++){var j=document.selectForm.elements[i];if (j.name==\\\"cancel\\\") {j.checked=x;}}} |
function cancelAll(x){for(i=0;i\\<document.selectForm.elements.length;i++){var j=document.selectForm.elements[i];if (j.name==\\\"cancel\\\") {j.checked=x;}}} |
333 |
function clearAll(x){for(i=0;i\\<document.selectForm.elements.length;i++){var j=document.selectForm.elements[i];if (j.type==\\\"checkbox\\\") {j.checked=x;}}}//--\\>\\</script\\> |
function clearAll(x){for(i=0;i\\<document.selectForm.elements.length;i++){var j=document.selectForm.elements[i];if (j.type==\\\"checkbox\\\") {j.checked=x;}}}//--\\>\\</script\\> |
334 |
"; |
"; |
335 |
|
|
336 |
Printf.bprintf buf "\\<form name=selectForm action=\\\"files\\\"\\>"; |
Printf.bprintf buf "\\<form name=selectForm action=\\\"files\\\"\\>"; |
337 |
|
|
338 |
|
|
339 |
Html.begin_table_option buf "width=100%"; |
Html.begin_table_option buf "width=100%"; |
340 |
|
|
341 |
Html.begin_td_option buf "width=50%"; |
Html.begin_td_option buf "width=50%"; |
342 |
Printf.bprintf buf "\\<input type=submit value='Submit changes'\\>"; |
Printf.bprintf buf "\\<input type=submit value='Submit changes'\\>"; |
343 |
Html.end_td buf; |
Html.end_td buf; |
344 |
|
|
345 |
Html.begin_td_option buf "width=50%"; |
Html.begin_td_option buf "width=50%"; |
346 |
Html.end_td buf; |
Html.end_td buf; |
347 |
|
|
348 |
Html.begin_td buf; |
Html.begin_td buf; |
349 |
Html.button buf "Pause all" "pauseAll(true);"; |
Html.button buf "Pause all" "pauseAll(true);"; |
350 |
Html.end_td buf; |
Html.end_td buf; |
351 |
|
|
352 |
Html.begin_td buf; |
Html.begin_td buf; |
353 |
Html.button buf "Resume all" "resumeAll(true);"; |
Html.button buf "Resume all" "resumeAll(true);"; |
354 |
Html.end_td buf; |
Html.end_td buf; |
355 |
|
|
356 |
Html.begin_td buf; |
Html.begin_td buf; |
357 |
Html.button buf "Cancel all" "cancelAll(true);"; |
Html.button buf "Cancel all" "cancelAll(true);"; |
358 |
Html.end_td buf; |
Html.end_td buf; |
359 |
|
|
360 |
Html.begin_td buf; |
Html.begin_td buf; |
361 |
Html.button buf "Clear all" "clearAll(false);"; |
Html.button buf "Clear all" "clearAll(false);"; |
362 |
Html.end_td buf; |
Html.end_td buf; |
363 |
|
|
364 |
Html.end_table buf; |
Html.end_table buf; |
365 |
|
|
366 |
print_table_html 10 buf |
print_table_html 10 buf |
367 |
[| Align_Left; Align_Left; Align_Left; Align_Right; Align_Right; Align_Right; Align_Right; Align_Right|] |
[| Align_Left; Align_Left; Align_Left; Align_Right; Align_Right; Align_Right; Align_Right; Align_Right|] |
368 |
[| |
[| |
369 |
"[ Num ]"; |
"[ Num ]"; |
370 |
"P/R/C"; |
"P/R/C"; |
371 |
"\\<input type=radio value=File name=sortby\\> File"; |
"\\<input type=radio value=File name=sortby\\> File"; |
372 |
"\\<input type=radio value=Percent name=sortby\\> Percent"; |
"\\<input type=radio value=Percent name=sortby\\> Percent"; |
373 |
"\\<input type=radio value=Downloaded name=sortby\\> Downloaded"; |
"\\<input type=radio value=Downloaded name=sortby\\> Downloaded"; |
374 |
"\\<input type=radio value=Size name=sortby\\> Size"; |
"\\<input type=radio value=Size name=sortby\\> Size"; |
375 |
"Old"; |
"Old"; |
376 |
"\\<input type=radio value=Rate name=sortby\\> Rate"; |
"\\<input type=radio value=Rate name=sortby\\> Rate"; |
377 |
"\\<input type=radio value=Priority name=sortby\\> Priority"; |
"\\<input type=radio value=Priority name=sortby\\> Priority"; |
378 |
|] |
|] |
379 |
(List.map (fun file -> |
(List.map (fun file -> |
380 |
[| |
[| |
381 |
(Printf.sprintf "[\\<a href=\\\"submit\\?q\\=vd+%d\\\"\\>%-5d\\</a\\> \\<a target=_blank href=http://donkeyfakes.gambri.net/fakecheck/update/fakecheck.php\\?size\\=%s\\&md4=%s\\>%s\\</a\\>]" |
(Printf.sprintf "[\\<a href=\\\"submit\\?q\\=vd+%d\\\"\\>%-5d\\</a\\> \\<a target=_blank href=http://donkeyfakes.gambri.net/fakecheck/update/fakecheck.php\\?size\\=%s\\&md4=%s\\>%s\\</a\\>]" |
382 |
file.file_num |
file.file_num |
383 |
file.file_num |
file.file_num |
384 |
(Int64.to_string file.file_size) |
(Int64.to_string file.file_size) |
387 |
); |
); |
388 |
|
|
389 |
(if downloading file then |
(if downloading file then |
390 |
Printf.sprintf |
Printf.sprintf |
391 |
"\\<input name=pause type=checkbox value=%d\\> R |
"\\<input name=pause type=checkbox value=%d\\> R |
392 |
\\<input name=cancel type=checkbox value=%d\\>" |
\\<input name=cancel type=checkbox value=%d\\>" |
393 |
file.file_num |
file.file_num |
394 |
file.file_num |
file.file_num |
395 |
else |
else |
396 |
Printf.sprintf |
Printf.sprintf |
397 |
"P |
"P |
398 |
\\<input name=resume type=checkbox value=%d\\> |
\\<input name=resume type=checkbox value=%d\\> |
399 |
\\<input name=cancel type=checkbox value=%d\\>" |
\\<input name=cancel type=checkbox value=%d\\>" |
400 |
file.file_num |
file.file_num |
401 |
file.file_num); |
file.file_num); |
402 |
|
|
403 |
( let size = Int64.to_float file.file_size in |
( let size = Int64.to_float file.file_size in |
404 |
let downloaded = Int64.to_float file.file_downloaded in |
let downloaded = Int64.to_float file.file_downloaded in |
405 |
let size = if size < 1. then 1. else size in |
let size = if size < 1. then 1. else size in |
414 |
(!!html_vd_barheight) |
(!!html_vd_barheight) |
415 |
(truncate ( (1. -. downloaded /. size) *. 100.)) |
(truncate ( (1. -. downloaded /. size) *. 100.)) |
416 |
); |
); |
417 |
|
|
418 |
(Printf.sprintf "%5.1f" (percent file)); |
(Printf.sprintf "%5.1f" (percent file)); |
419 |
(Int64.to_string file.file_downloaded); |
(Int64.to_string file.file_downloaded); |
420 |
(Int64.to_string file.file_size); |
(Int64.to_string file.file_size); |
421 |
(Printf.sprintf "%d:%s" |
(Printf.sprintf "%d:%s" |
422 |
(age_to_day file.file_age) |
(age_to_day file.file_age) |
423 |
( |
( |
424 |
let len = Array.length file.file_chunks_age in |
let len = Array.length file.file_chunks_age in |
425 |
if len = 0 then "-" else |
if len = 0 then "-" else |
426 |
let min = ref (last_time ()) in |
let min = ref (last_time ()) in |
427 |
for i = 0 to len - 1 do |
for i = 0 to len - 1 do |
428 |
if file.file_chunks_age.(i) < !min then |
if file.file_chunks_age.(i) < !min then |
430 |
done; |
done; |
431 |
if !min = 0 then "-" else |
if !min = 0 then "-" else |
432 |
string_of_int (age_to_day !min))); |
string_of_int (age_to_day !min))); |
433 |
|
|
434 |
(match file.file_state with |
(match file.file_state with |
435 |
| FileQueued -> "Queued" |
| FileQueued -> "Queued" |
436 |
| FilePaused -> "Paused" |
| FilePaused -> "Paused" |
437 |
| FileAborted s -> Printf.sprintf "Aborted %s" s |
| FileAborted s -> Printf.sprintf "Aborted %s" s |
438 |
| _ -> |
| _ -> |
439 |
if file.file_download_rate < 10.24 then |
if file.file_download_rate < 10.24 then |
440 |
"-" |
"-" |
441 |
else |
else |
445 |
) files); |
) files); |
446 |
Printf.bprintf buf "\\</form\\>" |
Printf.bprintf buf "\\</form\\>" |
447 |
|
|
448 |
|
|
449 |
let print_file_html_mods buf guifiles = |
let print_file_html_mods buf guifiles = |
450 |
|
|
451 |
if (List.length guifiles) > 0 then begin |
if (List.length guifiles) > 0 then begin |
452 |
let tsize = ref Int64.zero in |
let tsize = ref Int64.zero in |
453 |
let tdl = ref Int64.zero in |
let tdl = ref Int64.zero in |
456 |
let qdl = ref Int64.zero in |
let qdl = ref Int64.zero in |
457 |
let qnum = ref 0 in |
let qnum = ref 0 in |
458 |
|
|
459 |
List.iter (fun file -> |
List.iter (fun file -> |
460 |
tsize := Int64.add !tsize file.file_size; |
tsize := Int64.add !tsize file.file_size; |
461 |
tdl := Int64.add !tdl file.file_downloaded; |
tdl := Int64.add !tdl file.file_downloaded; |
462 |
trate := !trate +. file.file_download_rate; |
trate := !trate +. file.file_download_rate; |
468 |
end; |
end; |
469 |
|
|
470 |
) guifiles; |
) guifiles; |
471 |
|
|
472 |
Printf.bprintf buf "\\</pre\\> |
Printf.bprintf buf "\\</pre\\> |
473 |
\\<script language=JavaScript\\>\\<!-- |
\\<script language=JavaScript\\>\\<!-- |
474 |
function pauseAll(x){for(i=0;i\\<document.selectForm.elements.length;i++){var j=document.selectForm.elements[i];if (j.name==\\\"pause\\\") {j.checked=x;}}} |
function pauseAll(x){for(i=0;i\\<document.selectForm.elements.length;i++){var j=document.selectForm.elements[i];if (j.name==\\\"pause\\\") {j.checked=x;}}} |
484 |
var params=''; |
var params=''; |
485 |
if (selectID.value.length \\> 0) {params = '+'+selectID.value+'+'+num;} |
if (selectID.value.length \\> 0) {params = '+'+selectID.value+'+'+num;} |
486 |
var np = selectID.value; |
var np = selectID.value; |
487 |
if (np.charAt(0) == \\\"=\\\") {var p = parseInt(np.substring(1,99));} |
if (np.charAt(0) == \\\"=\\\") {var p = parseInt(np.substring(1,99));} |
488 |
else {var p = parseInt(cp) + parseInt(selectID.value);} |
else {var p = parseInt(cp) + parseInt(selectID.value);} |
489 |
var str='\\<select id=\\\"selectPriority' + num + '\\\" name=\\\"selectPriority' + num + '\\\" style=\\\"font-size: 8px; font-family: verdana\\\" onchange=\\\"javascript:submitPriority(' + num + ',' + p + ',this)\\\"\\>'; |
var str='\\<select id=\\\"selectPriority' + num + '\\\" name=\\\"selectPriority' + num + '\\\" style=\\\"font-size: 8px; font-family: verdana\\\" onchange=\\\"javascript:submitPriority(' + num + ',' + p + ',this)\\\"\\>'; |
490 |
if (p != 20 \\&\\& p != 10 \\&\\& p != 0 \\&\\& p != -10 \\&\\& p != -20) { str += '\\<OPTION value=\\\"=' + p + '\\\" SELECTED\\>' + p; } |
if (p != 20 \\&\\& p != 10 \\&\\& p != 0 \\&\\& p != -10 \\&\\& p != -20) { str += '\\<OPTION value=\\\"=' + p + '\\\" SELECTED\\>' + p; } |
506 |
|
|
507 |
\\<div class=main\\> |
\\<div class=main\\> |
508 |
\\<form id=\\\"selectForm\\\" name=\\\"selectForm\\\" action=\\\"files\\\"\\> |
\\<form id=\\\"selectForm\\\" name=\\\"selectForm\\\" action=\\\"files\\\"\\> |
509 |
\\<table class=main cellspacing=0 cellpadding=0\\> |
\\<table class=main cellspacing=0 cellpadding=0\\> |
510 |
|
|
511 |
\\<tr\\>\\<td\\> |
\\<tr\\>\\<td\\> |
512 |
|
|
538 |
Fifo.iter (fun (t,i,num,n,s) -> if t > !last_message_log then incr unread) chat_message_fifo; |
Fifo.iter (fun (t,i,num,n,s) -> if t > !last_message_log then incr unread) chat_message_fifo; |
539 |
if !unread > 0 then Printf.sprintf "\\<td class=downloaded title=\\\"%d unread messages\\\"\\>(+%d)\\ \\</td\\>" !unread !unread else ""); |
if !unread > 0 then Printf.sprintf "\\<td class=downloaded title=\\\"%d unread messages\\\"\\>(+%d)\\ \\</td\\>" !unread !unread else ""); |
540 |
|
|
541 |
if !!html_mods_vd_network then Printf.bprintf buf |
if !!html_mods_vd_network then Printf.bprintf buf |
542 |
"\\<td title=\\\"Sort by network\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=N name=sortby\\>\\</td\\>"; |
"\\<td title=\\\"Sort by network\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=N name=sortby\\>\\</td\\>"; |
543 |
|
|
544 |
Printf.bprintf buf |
Printf.bprintf buf |
545 |
"\\<td title=\\\"Sort by filename\\\" class=dlheader\\>\\<input class=headbutton type=submit value=File name=sortby\\>\\</td\\> |
"\\<td title=\\\"Sort by filename\\\" class=dlheader\\>\\<input class=headbutton type=submit value=File name=sortby\\>\\</td\\> |
546 |
\\<td title=\\\"Sort by size\\\" class=dlheader\\>\\<input class=headbutton type=submit value=Size name=sortby\\>\\</td\\> |
\\<td title=\\\"Sort by size\\\" class=dlheader\\>\\<input class=headbutton type=submit value=Size name=sortby\\>\\</td\\> |
547 |
\\<td title=\\\"Sort by size downloaded\\\" class=dlheader\\>\\<input class=\\\"headbutton ar\\\" type=submit value=DLed name=sortby\\>\\</td\\> |
\\<td title=\\\"Sort by size downloaded\\\" class=dlheader\\>\\<input class=\\\"headbutton ar\\\" type=submit value=DLed name=sortby\\>\\</td\\> |
548 |
\\<td title=\\\"Sort by percent\\\" class=dlheader\\>\\<input class=headbutton type=submit value=%% name=sortby\\>\\</td\\> |
\\<td title=\\\"Sort by percent\\\" class=dlheader\\>\\<input class=headbutton type=submit value=%% name=sortby\\>\\</td\\> |
549 |
\\<td title=\\\"Sort by number of sources\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=Srcs name=sortby\\>\\</td\\>"; |
\\<td title=\\\"Sort by number of sources\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=Srcs name=sortby\\>\\</td\\>"; |
550 |
|
|
551 |
if !!html_mods_vd_active_sources then Printf.bprintf buf |
if !!html_mods_vd_active_sources then Printf.bprintf buf |
552 |
"\\<td title=\\\"Sort by number of active sources\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=A name=sortby\\>\\</td\\>"; |
"\\<td title=\\\"Sort by number of active sources\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=A name=sortby\\>\\</td\\>"; |
553 |
|
|
554 |
Printf.bprintf buf |
Printf.bprintf buf |
555 |
"\\<td title=\\\"Sort by file availability percentage (using %s availability)\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=Avail name=sortby\\>\\</td\\>" |
"\\<td title=\\\"Sort by file availability percentage (using %s availability)\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=Avail name=sortby\\>\\</td\\>" |
556 |
(if !!html_mods_use_relative_availability then "Relative" else "Total"); |
(if !!html_mods_use_relative_availability then "Relative" else "Total"); |
557 |
|
|
558 |
if !!html_mods_vd_age then Printf.bprintf buf |
if !!html_mods_vd_age then Printf.bprintf buf |
559 |
"\\<td title=\\\"Sort by age of download\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=Age name=sortby\\>\\</td\\>"; |
"\\<td title=\\\"Sort by age of download\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=Age name=sortby\\>\\</td\\>"; |
560 |
|
|
561 |
if !!html_mods_vd_last then Printf.bprintf buf |
if !!html_mods_vd_last then Printf.bprintf buf |
562 |
"\\<td title=\\\"Sort by last seen complete\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=Last name=sortby\\>\\</td\\>"; |
"\\<td title=\\\"Sort by last seen complete\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=Last name=sortby\\>\\</td\\>"; |
563 |
|
|
564 |
Printf.bprintf buf |
Printf.bprintf buf |
565 |
"\\<td title=\\\"Sort by rate\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=Rate name=sortby\\>\\</td\\> |
"\\<td title=\\\"Sort by rate\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=Rate name=sortby\\>\\</td\\> |
566 |
\\<td title=\\\"Sort by estimated time of arrival\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=ETA name=sortby\\>\\</td\\>"; |
\\<td title=\\\"Sort by estimated time of arrival\\\" class=dlheader\\>\\<input style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton type=submit value=ETA name=sortby\\>\\</td\\>"; |
567 |
|
|
569 |
|
|
570 |
Printf.bprintf buf "\\</tr\\>"; |
Printf.bprintf buf "\\</tr\\>"; |
571 |
|
|
572 |
let ctd fn td = Printf.sprintf "\\<td onClick=\\\"location.href='submit?q=vd+%d';return true;\\\" class=\\\"dl ar\\\"\\>%s\\</td\\>" fn td in |
let ctd fn td = Printf.sprintf "\\<td onClick=\\\"location.href='submit?q=vd+%d';return true;\\\" class=\\\"dl ar\\\"\\>%s\\</td\\>" fn td in |
573 |
|
|
574 |
print_table_html_mods buf |
print_table_html_mods buf |
575 |
(List.map (fun file -> |
(List.map (fun file -> |
576 |
[| |
[| |
577 |
(if downloading file then |
(if downloading file then |
582 |
\\<td class=\\\"dl al brs\\\"\\>\\<input class=checkbox name=cancel type=checkbox value=%d\\>\\</td\\>" |
\\<td class=\\\"dl al brs\\\"\\>\\<input class=checkbox name=cancel type=checkbox value=%d\\>\\</td\\>" |
583 |
file.file_num |
file.file_num |
584 |
file.file_num |
file.file_num |
585 |
else |
else |
586 |
Printf.sprintf " |
Printf.sprintf " |
587 |
onMouseOver=\\\"mOvr(this);return true;\\\" onMouseOut=\\\"mOut(this);\\\"\\> |
onMouseOver=\\\"mOvr(this);return true;\\\" onMouseOut=\\\"mOut(this);\\\"\\> |
588 |
\\<td class=\\\"dl al np\\\"\\>P\\</td\\> |
\\<td class=\\\"dl al np\\\"\\>P\\</td\\> |
591 |
file.file_num |
file.file_num |
592 |
file.file_num); |
file.file_num); |
593 |
|
|
594 |
(if !!html_mods_vd_network then |
(if !!html_mods_vd_network then |
595 |
Printf.sprintf "\\<td onClick=\\\"location.href='submit?q=vd+%d';return true;\\\" |
Printf.sprintf "\\<td onClick=\\\"location.href='submit?q=vd+%d';return true;\\\" |
596 |
title=\\\"%s\\\" class=\\\"dl al\\\"\\>%s\\</td\\>" |
title=\\\"%s\\\" class=\\\"dl al\\\"\\>%s\\</td\\>" |
597 |
file.file_num (net_name file) (short_net_name file) else ""); |
file.file_num (net_name file) (short_net_name file) else ""); |
598 |
|
|
599 |
( let size = Int64.to_float file.file_size in |
( let size = Int64.to_float file.file_size in |
600 |
let downloaded = Int64.to_float file.file_downloaded in |
let downloaded = Int64.to_float file.file_downloaded in |
601 |
let size = if size < 1. then 1. else size in |
let size = if size < 1. then 1. else size in |
602 |
Printf.sprintf "\\<TD onClick=\\\"location.href='submit?q=vd+%d';return true;\\\" |
Printf.sprintf "\\<TD onClick=\\\"location.href='submit?q=vd+%d';return true;\\\" |
603 |
title=\\\"[File#: %d] [Net: %s]%s\\\" class=\\\"dl al\\\"\\>%s\\<br\\> |
title=\\\"[File#: %d] [Net: %s]%s\\\" class=\\\"dl al\\\"\\>%s\\<br\\> |
604 |
\\<table cellpadding=0 cellspacing=0 width=100%%\\>\\<tr\\> |
\\<table cellpadding=0 cellspacing=0 width=100%%\\>\\<tr\\> |
605 |
\\<td class=\\\"loaded\\\" style=\\\"height:%dpx\\\" width=\\\"%d%%\\\"\\> \\</td\\> |
\\<td class=\\\"loaded\\\" style=\\\"height:%dpx\\\" width=\\\"%d%%\\\"\\> \\</td\\> |
614 |
(truncate (downloaded /. size *. 100.)) |
(truncate (downloaded /. size *. 100.)) |
615 |
(!!html_vd_barheight) |
(!!html_vd_barheight) |
616 |
(truncate ( (1. -. downloaded /. size) *. 100.)) |
(truncate ( (1. -. downloaded /. size) *. 100.)) |
617 |
); |
); |
618 |
|
|
619 |
(ctd file.file_num (size_of_int64 file.file_size)); |
(ctd file.file_num (size_of_int64 file.file_size)); |
620 |
(ctd file.file_num (size_of_int64 file.file_downloaded)); |
(ctd file.file_num (size_of_int64 file.file_downloaded)); |
621 |
(ctd file.file_num (Printf.sprintf "%.1f" (percent file))); |
(ctd file.file_num (Printf.sprintf "%.1f" (percent file))); |
622 |
(ctd file.file_num (Printf.sprintf "%d" (number_of_sources file))); |
(ctd file.file_num (Printf.sprintf "%d" (number_of_sources file))); |
623 |
|
|
624 |
(if !!html_mods_vd_active_sources then |
(if !!html_mods_vd_active_sources then |
625 |
ctd file.file_num (Printf.sprintf "%d" (number_of_active_sources file)) |
ctd file.file_num (Printf.sprintf "%d" (number_of_active_sources file)) |
626 |
else ""); |
else ""); |
627 |
|
|
628 |
(ctd file.file_num (Printf.sprintf "%.0f" (get_file_availability file))); |
(ctd file.file_num (Printf.sprintf "%.0f" (get_file_availability file))); |
629 |
|
|
630 |
|
|
631 |
(if !!html_mods_vd_age then |
(if !!html_mods_vd_age then |
632 |
ctd file.file_num (let age = (BasicSocket.last_time ()) - file.file_age in time_to_string age) |
ctd file.file_num (let age = (BasicSocket.last_time ()) - file.file_age in time_to_string age) |
633 |
else ""); |
else ""); |
634 |
|
|
635 |
(if !!html_mods_vd_last then |
(if !!html_mods_vd_last then |
636 |
ctd file.file_num (if file.file_last_seen > 0 |
ctd file.file_num (if file.file_last_seen > 0 |
637 |
then let last = (BasicSocket.last_time ()) - file.file_last_seen in |
then let last = (BasicSocket.last_time ()) - file.file_last_seen in |
638 |
time_to_string last |
time_to_string last |
640 |
) |
) |
641 |
else "" |
else "" |
642 |
); |
); |
643 |
|
|
644 |
(ctd file.file_num |
(ctd file.file_num |
645 |
(match file.file_state with |
(match file.file_state with |
646 |
FilePaused -> "Paused" |
FilePaused -> "Paused" |
647 |
| FileQueued -> "Queued" |
| FileQueued -> "Queued" |
648 |
| _ -> if file.file_download_rate < 10.24 then "-" |
| _ -> if file.file_download_rate < 10.24 then "-" |
650 |
) |
) |
651 |
); |
); |
652 |
|
|
653 |
(ctd file.file_num (if (file.file_download_rate < 10.24 || stalled file) then "-" |
(ctd file.file_num (if (file.file_download_rate < 10.24 || stalled file) then "-" |
654 |
else time_to_string (calc_file_eta file)) ); |
else time_to_string (calc_file_eta file)) ); |
655 |
|
|
656 |
(if !!html_mods_vd_prio then |
(if !!html_mods_vd_prio then |
657 |
(Printf.sprintf "\\<td class=\\\"dl ar\\\"\\>\\<div id=\\\"divSelectPriority%d\\\"\\>\\<select id=\\\"selectPriority%d\\\" name=\\\"selectPriority%d\\\" |
(Printf.sprintf "\\<td class=\\\"dl ar\\\"\\>\\<div id=\\\"divSelectPriority%d\\\"\\>\\<select id=\\\"selectPriority%d\\\" name=\\\"selectPriority%d\\\" |
658 |
style=\\\"font-size: 8px; font-family: verdana\\\" onchange=\\\"javascript:submitPriority(%d,%d,this)\\\"\\>\n" |
style=\\\"font-size: 8px; font-family: verdana\\\" onchange=\\\"javascript:submitPriority(%d,%d,this)\\\"\\>\n" |
659 |
file.file_num file.file_num file.file_num file.file_num file.file_priority) |
file.file_num file.file_num file.file_num file.file_num file.file_priority) |
660 |
^ (match file.file_priority with 0 | -10 | 10 | -20 | 20 -> "" | _ -> |
^ (match file.file_priority with 0 | -10 | 10 | -20 | 20 -> "" | _ -> |
661 |
Printf.sprintf "\\<option value=\\\"=%d\\\" SELECTED\\>%d\n" file.file_priority file.file_priority) |
Printf.sprintf "\\<option value=\\\"=%d\\\" SELECTED\\>%d\n" file.file_priority file.file_priority) |
708 |
|
|
709 |
\\</tr\\> |
\\</tr\\> |
710 |
" (List.length files); |
" (List.length files); |
711 |
|
|
712 |
|
|
713 |
print_table_html_mods buf |
print_table_html_mods buf |
714 |
|
|
715 |
(List.map (fun file -> |
(List.map (fun file -> |
716 |
[| |
[| |
734 |
else if size > Int64.of_float 1073741824. then |
else if size > Int64.of_float 1073741824. then |
735 |
(Printf.sprintf "%5.1f%s" (Int64.to_float size /. 1073741824.) ("gb") ) |
(Printf.sprintf "%5.1f%s" (Int64.to_float size /. 1073741824.) ("gb") ) |
736 |
else if size < Int64.zero then |
else if size < Int64.zero then |
737 |
(Printf.sprintf "%d chunks" |
(Printf.sprintf "%d chunks" |
738 |
((String.length file.file_chunks)-(String.length (String2.replace (String2.replace file.file_chunks '0' "") '1' "")))) |
((String.length file.file_chunks)-(String.length (String2.replace (String2.replace file.file_chunks '0' "") '1' "")))) |
739 |
else (Printf.sprintf "%8s%s" (Int64.to_string size) ("b") ) ) |
else (Printf.sprintf "%8s%s" (Int64.to_string size) ("b") ) ) |
740 |
|
|
746 |
begin |
begin |
747 |
if !!html_mods then print_file_html_mods buf files |
if !!html_mods then print_file_html_mods buf files |
748 |
else |
else |
749 |
print_file_html_form buf files |
print_file_html_form buf files |
750 |
end |
end |
751 |
else |
else |
752 |
print_table buf |
print_table buf |
753 |
[| |
[| |
754 |
Align_Left; Align_Left; Align_Right; Align_Right; |
Align_Left; Align_Left; Align_Right; Align_Right; |
755 |
Align_Right; Align_Right; Align_Right |] |
Align_Right; Align_Right; Align_Right |] |
756 |
(if format.conn_output = HTML then |
(if format.conn_output = HTML then |
757 |
[| |
[| |
758 |
"[ Num ]"; |
"[ Num ]"; |
759 |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=name\\\"\\> File \\</a\\>"; |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=name\\\"\\> File \\</a\\>"; |
760 |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=percent\\\"\\> Percent \\</a\\>"; |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=percent\\\"\\> Percent \\</a\\>"; |
761 |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=done\\\"\\> Downloaded \\</a\\>"; |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=done\\\"\\> Downloaded \\</a\\>"; |
762 |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=size\\\"\\> Size \\</a\\>"; |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=size\\\"\\> Size \\</a\\>"; |
763 |
"Old"; |
"Old"; |
764 |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=rate\\\"\\> Rate \\</a\\>"; |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=rate\\\"\\> Rate \\</a\\>"; |
765 |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=priority\\\"\\> Priority \\</a\\>"; |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=priority\\\"\\> Priority \\</a\\>"; |
766 |
|] else |
|] else |
767 |
[| |
[| |
768 |
"$nNum"; |
"$nNum"; |
769 |
"File"; |
"File"; |
770 |
" %"; |
" %"; |
771 |
" Done"; |
" Done"; |
772 |
" Size"; |
" Size"; |
773 |
"Avail"; |
"Avail"; |
775 |
" Active"; |
" Active"; |
776 |
"Rate"; |
"Rate"; |
777 |
"Prio"; |
"Prio"; |
778 |
|] |
|] |
779 |
) |
) |
780 |
(List.map (fun file -> |
(List.map (fun file -> |
781 |
let rate, color = |
let rate, color = |
794 |
(Printf.sprintf "%0s[%0s]%0s" |
(Printf.sprintf "%0s[%0s]%0s" |
795 |
(if !!term_ansi then (color) |
(if !!term_ansi then (color) |
796 |
else "") |
else "") |
797 |
(if format.conn_output = HTML then |
(if format.conn_output = HTML then |
798 |
(Printf.sprintf "\\<a href=\\\"submit\\?q\\=vd\\+%d\\\" $S\\>%0s%4d\\</a\\>" |
(Printf.sprintf "\\<a href=\\\"submit\\?q\\=vd\\+%d\\\" $S\\>%0s%4d\\</a\\>" |
799 |
file.file_num |
file.file_num |
800 |
(short_net_name file) |
(short_net_name file) |
803 |
(Printf.sprintf "%0s%4d" |
(Printf.sprintf "%0s%4d" |
804 |
(short_net_name file) |
(short_net_name file) |
805 |
file.file_num)) |
file.file_num)) |
806 |
(if format.conn_output = HTML then |
(if format.conn_output = HTML then |
807 |
Printf.sprintf "[\\<a href=\\\"submit\\?q\\=cancel\\+%d\\\" $S\\>CANCEL\\</a\\>][\\<a href=\\\"submit\\?q\\=%s\\+%d\\\" $S\\>%s\\</a\\>] " |
Printf.sprintf "[\\<a href=\\\"submit\\?q\\=cancel\\+%d\\\" $S\\>CANCEL\\</a\\>][\\<a href=\\\"submit\\?q\\=%s\\+%d\\\" $S\\>%s\\</a\\>] " |
808 |
file.file_num |
file.file_num |
809 |
(if downloading file then "pause" else "resume" ) |
(if downloading file then "pause" else "resume" ) |
810 |
file.file_num |
file.file_num |
811 |
(if downloading file then "PAUSE" else "RESUME") |
(if downloading file then "PAUSE" else "RESUME") |
812 |
else "")); |
else "")); |
816 |
else (Int64.to_string file.file_downloaded) ); |
else (Int64.to_string file.file_downloaded) ); |
817 |
(if !!improved_telnet then (print_human_readable file file.file_size) |
(if !!improved_telnet then (print_human_readable file file.file_size) |
818 |
else (Int64.to_string file.file_size) ); |
else (Int64.to_string file.file_size) ); |
819 |
(Printf.sprintf "%.0f%%" (get_file_availability file)); |
(Printf.sprintf "%.0f%%" (get_file_availability file)); |
820 |
(Printf.sprintf "%d:%s" (age_to_day file.file_age) |
(Printf.sprintf "%d:%s" (age_to_day file.file_age) |
821 |
( |
( |
822 |
let len = Array.length file.file_chunks_age in |
let len = Array.length file.file_chunks_age in |
823 |
if len = 0 then "-" else |
if len = 0 then "-" else |
824 |
let min = ref (last_time ()) in |
let min = ref (last_time ()) in |
825 |
for i = 0 to len - 1 do |
for i = 0 to len - 1 do |
826 |
if file.file_chunks_age.(i) < !min then |
if file.file_chunks_age.(i) < !min then |
834 |
|] |
|] |
835 |
) files) |
) files) |
836 |
else |
else |
837 |
if use_html_mods format then |
if use_html_mods format then |
838 |
html_mods_done_files buf files |
html_mods_done_files buf files |
839 |
else |
else |
840 |
|
|
841 |
print_table buf |
print_table buf |
842 |
[||] |
[||] |
843 |
(if format.conn_output = HTML then |
(if format.conn_output = HTML then |
844 |
[| |
[| |
845 |
"[ Num ]"; |
"[ Num ]"; |
846 |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=name\\\"\\> File \\</a\\>"; |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=name\\\"\\> File \\</a\\>"; |
847 |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=size\\\"\\> Size \\</a\\>"; |
"\\<a href=\\\"submit\\?q\\=vd\\&sortby\\=size\\\"\\> Size \\</a\\>"; |
848 |
"MD4"; |
"MD4"; |
849 |
|] |
|] |
850 |
else |
else |
851 |
[| |
[| |
852 |
"[ Num ]"; |
"[ Num ]"; |
853 |
"File"; |
"File"; |
854 |
"Size"; |
"Size"; |
855 |
"MD4"; |
"MD4"; |
856 |
|] |
|] |
857 |
) |
) |
858 |
(List.map (fun file -> |
(List.map (fun file -> |
859 |
[| |
[| |
860 |
(Printf.sprintf "[%s %-5d]" |
(Printf.sprintf "[%s %-5d]" |
861 |
(net_name file) |
(net_name file) |
862 |
file.file_num); |
file.file_num); |
863 |
(short_name file); |
(short_name file); |
864 |
(Int64.to_string file.file_size); |
(Int64.to_string file.file_size); |
865 |
(Md4.to_string file.file_md4) |
(Md4.to_string file.file_md4) |
866 |
|] |
|] |
867 |
) files) |
) files) |
868 |
|
|
869 |
let display_file_list buf o = |
let display_file_list buf o = |
870 |
display_vd := true; |
display_vd := true; |
871 |
if not (use_html_mods o) then |
if not (use_html_mods o) then |
872 |
(* Printf.bprintf buf "Downloaded %d/%d files\n" (List.length !!done_files) |
(* Printf.bprintf buf "Downloaded %d/%d files\n" (List.length !!done_files) |
873 |
(List.length !!files); *) |
(List.length !!files); *) |
874 |
Printf.bprintf buf "\nDown: %.1f KB/s ( %d + %d ) | Up: %.1f KB/s ( %d + %d ) | Shared: %d/%s" |
Printf.bprintf buf "\nDown: %.1f KB/s ( %d + %d ) | Up: %.1f KB/s ( %d + %d ) | Shared: %d/%s" |
875 |
(( (float_of_int !udp_download_rate) +. (float_of_int !control_download_rate)) /. 1024.0) |
(( (float_of_int !udp_download_rate) +. (float_of_int !control_download_rate)) /. 1024.0) |
891 |
end |
end |
892 |
else |
else |
893 |
let list = List2.tail_map file_info !!files in |
let list = List2.tail_map file_info !!files in |
894 |
let list = |
let list = |
895 |
try |
try |
896 |
let sorter = |
let sorter = |
897 |
match o.conn_sortvd with |
match o.conn_sortvd with |
898 |
|
|
899 |
| BySize -> (fun f1 f2 -> f1.file_size >= f2.file_size) |
| BySize -> (fun f1 f2 -> f1.file_size >= f2.file_size) |
900 |
| ByRate -> (fun f1 f2 -> |
| ByRate -> (fun f1 f2 -> |
901 |
if stalled f1 then false else |
if stalled f1 then false else |
902 |
if stalled f2 then true else |
if stalled f2 then true else |
903 |
f1.file_download_rate >= f2.file_download_rate |
f1.file_download_rate >= f2.file_download_rate |
939 |
|
|
940 |
|
|
941 |
let get_tag_value tag = |
let get_tag_value tag = |
942 |
match tag.tag_value with |
match tag.tag_value with |
943 |
| Uint64 i -> String.escaped (Int64.to_string i) |
| Uint64 i -> String.escaped (Int64.to_string i) |
944 |
| Fint64 i -> String.escaped (Int64.to_string i) |
| Fint64 i -> String.escaped (Int64.to_string i) |
945 |
| String s -> String.escaped s |
| String s -> String.escaped s |
946 |
| _ -> "" |
| _ -> "" |
947 |
|
|
948 |
let old_print_search buf o results = |
let old_print_search buf o results = |
949 |
let user = o.conn_user in |
let user = o.conn_user in |
950 |
let counter = ref 0 in |
let counter = ref 0 in |
951 |
if use_html_mods o then |
if use_html_mods o then |
952 |
html_mods_table_header buf "resultsTable" "results" [ |
html_mods_table_header buf "resultsTable" "results" [ |
953 |
( "0", "srh", "Network", "Network" ) ; |
( "0", "srh", "Network", "Network" ) ; |
954 |
( "0", "srh", "File", "File (mouseover)" ) ; |
( "0", "srh", "File", "File (mouseover)" ) ; |
955 |
( "1", "srh ar", "Size", "Size" ) ; |
( "1", "srh ar", "Size", "Size" ) ; |
956 |
( "1", "srh ar", "Availability", "A" ) ; |
( "1", "srh ar", "Availability", "A" ) ; |
957 |
( "1", "srh ar", "Complete Sources", "C" ) ; |
( "1", "srh ar", "Complete Sources", "C" ) ; |
958 |
( "0", "srh", "Hash (click for bitzi lookup)", "Hash (bitzi click)" ) ; |
( "0", "srh", "Hash (click for bitzi lookup)", "Hash (bitzi click)" ) ; |
959 |
( "0", "srh", "Tags", "Tags (mouseover)" ) ] ; |
( "0", "srh", "Tags", "Tags (mouseover)" ) ] ; |
960 |
|
|
961 |
(try |
(try |
962 |
List.iter (fun (rs,r,avail) -> |
List.iter (fun (rs,r,avail) -> |
963 |
if !!display_downloaded_results || not r.result_done then begin |
if !!display_downloaded_results || not r.result_done then begin |
964 |
incr counter; |
incr counter; |
965 |
if !counter >= !!max_displayed_results then raise Exit; |
if !counter >= !!max_displayed_results then raise Exit; |
966 |
|
|
967 |
if use_html_mods o then |
if use_html_mods o then |
968 |
begin |
begin |
969 |
if (!counter mod 2 == 0) then Printf.bprintf buf "\\<tr class=\\\"dl-1\\\"\\>" |
if (!counter mod 2 == 0) then Printf.bprintf buf "\\<tr class=\\\"dl-1\\\"\\>" |
970 |
else Printf.bprintf buf "\\<tr class=\\\"dl-2\\\"\\>"; |
else Printf.bprintf buf "\\<tr class=\\\"dl-2\\\"\\>"; |
971 |
end; |
end; |
972 |
|
|
973 |
user.ui_last_results <- (!counter, rs) :: user.ui_last_results; |
user.ui_last_results <- (!counter, rs) :: user.ui_last_results; |
974 |
if use_html_mods o then Printf.bprintf buf "\\<td class=\\\"sr\\\"\\>%s\\</td\\>" |
if use_html_mods o then Printf.bprintf buf "\\<td class=\\\"sr\\\"\\>%s\\</td\\>" |
975 |
( |
( |
976 |
(* TODO RESULT: use the uids to display from which networks it is downloadable |
(* TODO RESULT: use the uids to display from which networks it is downloadable |
977 |
let n = network_find_by_num r.result_network in |
let n = network_find_by_num r.result_network in |
978 |
n.network_name *) "--") |
n.network_name *) "--") |
979 |
else Printf.bprintf buf "[%5d] %s " |
else Printf.bprintf buf "[%5d] %s " |
980 |
!counter |
!counter |
981 |
|
|
982 |
(* TODO RESULT: |
(* TODO RESULT: |
983 |
(let n = network_find_by_num r.result_network in |
(let n = network_find_by_num r.result_network in |
984 |
n.network_name) *) |
n.network_name) *) |
985 |
"--"; |
"--"; |
986 |
|
|
987 |
if o.conn_output = HTML then begin |
if o.conn_output = HTML then begin |
988 |
if !!html_mods then begin |
if !!html_mods then begin |
989 |
Printf.bprintf buf "\\<td title=\\\""; |
Printf.bprintf buf "\\<td title=\\\""; |
990 |
let nl = ref false in |
let nl = ref false in |
991 |
List.iter (fun t -> |
List.iter (fun t -> |
992 |
match t.tag_name with |
match t.tag_name with |
993 |
| Field_UNKNOWN "FTH" | Field_UNKNOWN "urn" -> () |
| Field_UNKNOWN "FTH" | Field_UNKNOWN "urn" -> () |
994 |
| _ -> |
| _ -> |
995 |
Buffer.add_string buf ((if !nl then "\n" else begin nl := true;"" end) ^ |
Buffer.add_string buf ((if !nl then "\n" else begin nl := true;"" end) ^ |
996 |
"|| (" ^ |
"|| (" ^ |
997 |
escaped_string_of_field t ^ "): " ^ get_tag_value t); |
escaped_string_of_field t ^ "): " ^ get_tag_value t); |
998 |
) r.result_tags; |
) r.result_tags; |
999 |
|
|
1000 |
Printf.bprintf buf "\\\" class=\\\"sr\\\"\\>\\<a href=results\\?d=%d target=\\\"$S\\\"\\>" r.result_num |
Printf.bprintf buf "\\\" class=\\\"sr\\\"\\>\\<a href=results\\?d=%d target=\\\"$S\\\"\\>" r.result_num |
1001 |
end |
end |
1002 |
else Printf.bprintf buf "\\<a href=results\\?d=%d $S\\>" r.result_num; |
else Printf.bprintf buf "\\<a href=results\\?d=%d $S\\>" r.result_num; |
1006 |
[] -> () |
[] -> () |
1007 |
| name :: names -> |
| name :: names -> |
1008 |
Printf.bprintf buf "%s\n" (shorten name !!max_name_len); |
Printf.bprintf buf "%s\n" (shorten name !!max_name_len); |
1009 |
List.iter (fun s -> |
List.iter (fun s -> |
1010 |
if use_html_mods o then Printf.bprintf buf "\\<BR\\>"; |
if use_html_mods o then Printf.bprintf buf "\\<BR\\>"; |
1011 |
Printf.bprintf buf " %s\n" s |
Printf.bprintf buf " %s\n" s |
1012 |
) names; |
) names; |
1013 |
end; |
end; |
1014 |
if r.result_done then |
if r.result_done then |
1015 |
begin |
begin |
1016 |
if use_html_mods o then Printf.bprintf buf "\\<BR\\>"; |
if use_html_mods o then Printf.bprintf buf "\\<BR\\>"; |
1017 |
Printf.bprintf buf " ALREADY DOWNLOADED\n " |
Printf.bprintf buf " ALREADY DOWNLOADED\n " |
1024 |
Printf.bprintf buf "COMMENT: %s\n" comment |
Printf.bprintf buf "COMMENT: %s\n" comment |
1025 |
end; |
end; |
1026 |
end; |
end; |
1027 |
if o.conn_output = HTML then |
if o.conn_output = HTML then |
1028 |
begin |
begin |
1029 |
if !!html_mods then Printf.bprintf buf "\\</a\\>\\</td\\>" |
if !!html_mods then Printf.bprintf buf "\\</a\\>\\</td\\>" |
1030 |
else Printf.bprintf buf "\\</a href\\>"; |
else Printf.bprintf buf "\\</a href\\>"; |
1033 |
let cavail = ref (string_of_int avail) in |
let cavail = ref (string_of_int avail) in |
1034 |
let csource = ref "" in |
let csource = ref "" in |
1035 |
List.iter (fun t -> |
List.iter (fun t -> |
1036 |
(match t.tag_name with |
(match t.tag_name with |
1037 |
| Field_UNKNOWN "urn" |
| Field_UNKNOWN "urn" |
1038 |
| Field_UNKNOWN "FTH" -> hash := get_tag_value t |
| Field_UNKNOWN "FTH" -> hash := get_tag_value t |
1039 |
| Field_Availability -> cavail := get_tag_value t |
| Field_Availability -> cavail := get_tag_value t |
1040 |
| Field_Completesources -> csource := get_tag_value t |
| Field_Completesources -> csource := get_tag_value t |
1041 |
| _ -> ())) r.result_tags; |
| _ -> ())) r.result_tags; |
1042 |
|
|
1043 |
if use_html_mods o then |
if use_html_mods o then |
1044 |
Printf.bprintf buf "\\<td class=\\\"sr ar\\\"\\>%s\\</td\\> |
Printf.bprintf buf "\\<td class=\\\"sr ar\\\"\\>%s\\</td\\> |
1045 |
\\<td class=\\\"sr ar\\\"\\>%s\\</td\\> |
\\<td class=\\\"sr ar\\\"\\>%s\\</td\\> |
1046 |
\\<td class=\\\"sr ar\\\"\\>%s\\</td\\> |
\\<td class=\\\"sr ar\\\"\\>%s\\</td\\> |
1048 |
(size_of_int64 r.result_size) |
(size_of_int64 r.result_size) |
1049 |
!cavail |
!cavail |
1050 |
!csource |
!csource |
1051 |
|
|
1052 |
(if String.contains !hash ':' then |
(if String.contains !hash ':' then |
1053 |
String.sub !hash |
String.sub !hash |
1054 |
((String.rindex !hash ':')+1) |
((String.rindex !hash ':')+1) |
1055 |
((String.length !hash) - (String.rindex !hash ':') - 1) |
((String.length !hash) - (String.rindex !hash ':') - 1) |
1056 |
else !hash) !hash |
else !hash) !hash |
1057 |
else Printf.bprintf buf " %10s %10s " |
else Printf.bprintf buf " %10s %10s " |
1058 |
(Int64.to_string r.result_size) |
(Int64.to_string r.result_size) |
1059 |
(string_of_uids r.result_uids); |
(string_of_uids r.result_uids); |
1060 |
|
|
1061 |
if use_html_mods o then begin |
if use_html_mods o then begin |
1062 |
Printf.bprintf buf "\\<td class=\\\"sr\\\"\\>"; |
Printf.bprintf buf "\\<td class=\\\"sr\\\"\\>"; |
1063 |
List.iter (fun t -> |
List.iter (fun t -> |
1064 |
(match t.tag_name with |
(match t.tag_name with |
1065 |
| Field_Completesources |
| Field_Completesources |
1066 |
| Field_Availability |
| Field_Availability |
1067 |
(* TODO : "urn" shouldn't be some kind of Field_Uid of Gnutella ? *) |
(* TODO : "urn" shouldn't be some kind of Field_Uid of Gnutella ? *) |
1068 |
| Field_UNKNOWN "urn" |
| Field_UNKNOWN "urn" |
1069 |
(* TODO : "FTH" shouldn't be some kind of Field_Uid of Fasttrack ? *) |
(* TODO : "FTH" shouldn't be some kind of Field_Uid of Fasttrack ? *) |
1070 |
| Field_UNKNOWN "FTH" -> () |
| Field_UNKNOWN "FTH" -> () |
1071 |
| _ -> |
| _ -> |
1072 |
Buffer.add_string buf ("\\<span title=\\\"" ^ |
Buffer.add_string buf ("\\<span title=\\\"" ^ |
1073 |
get_tag_value t ^ "\\\"\\>(" ^ |
get_tag_value t ^ "\\\"\\>(" ^ |
1074 |
escaped_string_of_field t ^ ") \\</span\\>"); |
escaped_string_of_field t ^ ") \\</span\\>"); |
1075 |
) |
) |
1076 |
) r.result_tags; |
) r.result_tags; |
1087 |
) results; |
) results; |
1088 |
if use_html_mods o then Printf.bprintf buf "\\</table\\>" |
if use_html_mods o then Printf.bprintf buf "\\</table\\>" |
1089 |
with _ -> ()) |
with _ -> ()) |
1090 |
|
|
1091 |
|
|
1092 |
let add_filter_table buf search_num = |
let add_filter_table buf search_num = |
1093 |
|
|
1094 |
Printf.bprintf buf "\\<form action=\\\"filter\\\"\\>"; |
Printf.bprintf buf "\\<form action=\\\"filter\\\"\\>"; |
1095 |
Printf.bprintf buf "\\<input type=hidden name=num value=%d\\>" search_num; |
Printf.bprintf buf "\\<input type=hidden name=num value=%d\\>" search_num; |
1096 |
|
|
1097 |
Printf.bprintf buf "\\<table\\>"; |
Printf.bprintf buf "\\<table\\>"; |
1098 |
Printf.bprintf buf "\\<tr\\>"; |
Printf.bprintf buf "\\<tr\\>"; |
1099 |
|
|
1100 |
Printf.bprintf buf "\\<td\\>"; |
Printf.bprintf buf "\\<td\\>"; |
1101 |
Printf.bprintf buf "\\<input type=submit value='Filter Out'\\>"; |
Printf.bprintf buf "\\<input type=submit value='Filter Out'\\>"; |
1102 |
Printf.bprintf buf "\\</td\\>"; |
Printf.bprintf buf "\\</td\\>"; |
1103 |
|
|
1104 |
Printf.bprintf buf "\\</tr\\>\\<tr\\>"; |
Printf.bprintf buf "\\</tr\\>\\<tr\\>"; |
1105 |
|
|
1106 |
Printf.bprintf buf "\\<td\\>\\<table\\>\\<tr\\>"; |
Printf.bprintf buf "\\<td\\>\\<table\\>\\<tr\\>"; |
1107 |
|
|
1108 |
Printf.bprintf buf "\\<table\\>"; |
Printf.bprintf buf "\\<table\\>"; |
1109 |
Printf.bprintf buf "\\<td\\> Media: \\</td\\>"; |
Printf.bprintf buf "\\<td\\> Media: \\</td\\>"; |
1110 |
Printf.bprintf buf "\\<td\\>\\<input name=media type=checkbox value=Audio\\> Audio \\</td\\>"; |
Printf.bprintf buf "\\<td\\>\\<input name=media type=checkbox value=Audio\\> Audio \\</td\\>"; |
1114 |
Printf.bprintf buf "\\</table\\>"; |
Printf.bprintf buf "\\</table\\>"; |
1115 |
|
|
1116 |
Printf.bprintf buf "\\</tr\\>\\<tr\\>"; |
Printf.bprintf buf "\\</tr\\>\\<tr\\>"; |
1117 |
|
|
1118 |
Printf.bprintf buf "\\<table\\>"; |
Printf.bprintf buf "\\<table\\>"; |
1119 |
Printf.bprintf buf "\\<td\\> Formats: \\</td\\>"; |
Printf.bprintf buf "\\<td\\> Formats: \\</td\\>"; |
1120 |
Printf.bprintf buf "\\<td\\>\\<input name=format type=checkbox value=mp3\\> Mp3 \\</td\\>"; |
Printf.bprintf buf "\\<td\\>\\<input name=format type=checkbox value=mp3\\> Mp3 \\</td\\>"; |
1124 |
Printf.bprintf buf "\\</table\\>"; |
Printf.bprintf buf "\\</table\\>"; |
1125 |
|
|
1126 |
Printf.bprintf buf "\\</tr\\>\\<tr\\>"; |
Printf.bprintf buf "\\</tr\\>\\<tr\\>"; |
1127 |
|
|
1128 |
Printf.bprintf buf "\\<table\\>"; |
Printf.bprintf buf "\\<table\\>"; |
1129 |
Printf.bprintf buf "\\<td\\> Sizes: \\</td\\>"; |
Printf.bprintf buf "\\<td\\> Sizes: \\</td\\>"; |
1130 |
Printf.bprintf buf "\\<td\\>\\<input name=size type=checkbox value=0to5\\> 0/5 MB \\</td\\>"; |
Printf.bprintf buf "\\<td\\>\\<input name=size type=checkbox value=0to5\\> 0/5 MB \\</td\\>"; |
1137 |
Printf.bprintf buf "\\</tr\\>"; |
Printf.bprintf buf "\\</tr\\>"; |
1138 |
|
|
1139 |
Printf.bprintf buf "\\</table\\>"; |
Printf.bprintf buf "\\</table\\>"; |
1140 |
|
|
1141 |
Printf.bprintf buf "\\</form\\>" |
Printf.bprintf buf "\\</form\\>" |
1142 |
|
|
1143 |
(* with checkboxes *) |
(* with checkboxes *) |
1144 |
let print_search_html buf results o search_num = |
let print_search_html buf results o search_num = |
1145 |
let user = o.conn_user in |
let user = o.conn_user in |
1146 |
let counter = ref 0 in |
let counter = ref 0 in |
1147 |
|
|
1148 |
let files = ref [] in |
let files = ref [] in |
1149 |
|
|
1150 |
(try |
(try |
1151 |
List.iter (fun (rs, r, avail) -> |
List.iter (fun (rs, r, avail) -> |
1152 |
|
|
1153 |
try |
try |
1154 |
o.conn_filter r; |
o.conn_filter r; |
1155 |
if !!display_downloaded_results || not r.result_done then |
if !!display_downloaded_results || not r.result_done then |
1156 |
let tags_string = |
let tags_string = |
1157 |
let buf = Buffer.create 100 in |
let buf = Buffer.create 100 in |
1158 |
List.iter (fun t -> |
List.iter (fun t -> |
1159 |
Buffer.add_string buf (Printf.sprintf "%-3s " |
Buffer.add_string buf (Printf.sprintf "%-3s " |
1171 |
if !counter >= !!max_displayed_results then raise Exit; |
if !counter >= !!max_displayed_results then raise Exit; |
1172 |
user.ui_last_results <- (!counter, rs) :: user.ui_last_results; |
user.ui_last_results <- (!counter, rs) :: user.ui_last_results; |
1173 |
files := [| |
files := [| |
1174 |
|
|
1175 |
(Int64.to_string r.result_size); |
(Int64.to_string r.result_size); |
1176 |
(string_of_int avail); |
(string_of_int avail); |
1177 |
(Printf.sprintf "[%5d]\\<input name=d type=checkbox value=%d\\>" !counter r.result_num); |
(Printf.sprintf "[%5d]\\<input name=d type=checkbox value=%d\\>" !counter r.result_num); |
1178 |
|
|
1179 |
( |
( |
1180 |
let names = r.result_names in |
let names = r.result_names in |
1181 |
let names = if r.result_done then |
let names = if r.result_done then |
1182 |
names @ ["ALREADY DOWNLOADED"] else names in |
names @ ["ALREADY DOWNLOADED"] else names in |
1183 |
let names = match r.result_comment with |
let names = match r.result_comment with |
1184 |
| "" -> names |
| "" -> names |
1185 |
| comment -> |
| comment -> |
1186 |
names @ ["COMMENT: " ^ comment] |
names @ ["COMMENT: " ^ comment] |
1187 |
in |
in |
1188 |
match names with |
match names with |
1189 |
[name] -> name |
[name] -> name |
1190 |
| _ -> |
| _ -> |
1191 |
let buf = Buffer.create 100 in |
let buf = Buffer.create 100 in |
1192 |
Buffer.add_string buf "\\<table\\>\n"; |
Buffer.add_string buf "\\<table\\>\n"; |
1193 |
List.iter (fun s -> |
List.iter (fun s -> |
1194 |
Buffer.add_string buf "\\<tr\\>\\<td\\>"; |
Buffer.add_string buf "\\<tr\\>\\<td\\>"; |
1195 |
Buffer.add_string buf s; |
Buffer.add_string buf s; |
1196 |
Buffer.add_string buf "\\</td\\>\\</tr\\>"; |
Buffer.add_string buf "\\</td\\>\\</tr\\>"; |
1197 |
) names; |
) names; |
1198 |
Buffer.add_string buf "\\</table\\>\n"; |
Buffer.add_string buf "\\</table\\>\n"; |
1199 |
|
|
1200 |
Buffer.contents buf |
Buffer.contents buf |
1201 |
); |
); |
1202 |
|
|
1203 |
tags_string; |
tags_string; |
1204 |
|
|
1205 |
|
|
1206 |
(string_of_uids r.result_uids); |
(string_of_uids r.result_uids); |
1207 |
|] :: !files |
|] :: !files |
1208 |
with _ -> () |
with _ -> () |
1209 |
) results; |
) results; |
1210 |
with _ -> ()); |
with _ -> ()); |
1211 |
|
|
1212 |
if !counter > !!filter_table_threshold then |
if !counter > !!filter_table_threshold then |
1213 |
add_filter_table buf search_num; |
add_filter_table buf search_num; |
1214 |
|
|
1215 |
Printf.bprintf buf "\\<form action=results\\>"; |
Printf.bprintf buf "\\<form action=results\\>"; |
1216 |
Printf.bprintf buf "\\<input type=submit value='Submit Changes'\\>"; |
Printf.bprintf buf "\\<input type=submit value='Submit Changes'\\>"; |
1217 |
print_table_html 10 buf [||] |
print_table_html 10 buf [||] |
1218 |
[| |
[| |
1219 |
"[ Num ]"; |
"[ Num ]"; |
1220 |
"Size"; |
"Size"; |
1222 |
"Names"; |
"Names"; |
1223 |
"Tags"; |
"Tags"; |
1224 |
"MD4"; |
"MD4"; |
1225 |
|] |
|] |
1226 |
(List.rev !files); |
(List.rev !files); |
1227 |
Printf.bprintf buf "\\</form\\>" |
Printf.bprintf buf "\\</form\\>" |
1228 |
|
|
1229 |
|
|
1230 |
|
|
|
|
|
|
|
|
1231 |
let print_results stime buf o results = |
let print_results stime buf o results = |
1232 |
|
|
1233 |
let user = o.conn_user in |
let user = o.conn_user in |
1234 |
let print_table = if o.conn_output = HTML then print_table_html 2 |
let print_table = if o.conn_output = HTML then print_table_html 2 |
1235 |
else print_table_text in |
else print_table_text in |
1236 |
|
|
1237 |
let counter = ref 0 in |
let counter = ref 0 in |
1238 |
let nsources = ref 0 in |
let nsources = ref 0 in |
1239 |
let totalsize = ref 0L in |
let totalsize = ref 0L in |
1248 |
user.ui_last_results <- (!counter, rs) :: user.ui_last_results; |
user.ui_last_results <- (!counter, rs) :: user.ui_last_results; |
1249 |
let new_result = !!save_results > 0 && r.result_time >= stime in |
let new_result = !!save_results > 0 && r.result_time >= stime in |
1250 |
files := [| |
files := [| |
1251 |
|
|
1252 |
(if use_html_mods o then |
(if use_html_mods o then |
1253 |
Printf.sprintf "\\>\\<td class=\\\"sr\\\"\\>%d\\</td\\>" !counter |
Printf.sprintf "\\>\\<td class=\\\"sr\\\"\\>%d\\</td\\>" !counter |
1254 |
else Printf.sprintf "%s[%s%5d]" |
else Printf.sprintf "%s[%s%5d]" |
1255 |
(if new_result && !!term_ansi then "$b" else "$n") |
(if new_result && !!term_ansi then "$b" else "$n") |
1256 |
(if new_result then "N" else " ") |
(if new_result then "N" else " ") |
1257 |
!counter); |
!counter); |
1258 |
|
|
1259 |
|
|
1260 |
(if use_html_mods o then |
(if use_html_mods o then |
1261 |
"\\<td class=\\\"sr ar\\\"\\>" ^ size_of_int64 r.result_size ^ "\\</td\\>" |
"\\<td class=\\\"sr ar\\\"\\>" ^ size_of_int64 r.result_size ^ "\\</td\\>" |
1262 |
else Int64.to_string r.result_size |
else Int64.to_string r.result_size |
1263 |
); |
); |
1264 |
|
|
1265 |
(if use_html_mods o then |
(if use_html_mods o then |
1266 |
"\\<td class=\\\"sr ar\\\"\\>" ^ (string_of_int avail) ^ "\\</td\\>" |
"\\<td class=\\\"sr ar\\\"\\>" ^ (string_of_int avail) ^ "\\</td\\>" |
1267 |
else (string_of_int avail) |
else (string_of_int avail) |
1268 |
); |
); |
1269 |
|
|
1270 |
(Printf.sprintf "%s%s%s" |
(Printf.sprintf "%s%s%s" |
1271 |
(if o.conn_output = HTML then begin |
(if o.conn_output = HTML then begin |
1272 |
if !!html_mods then Printf.sprintf "\\<td class=\\\"sr\\\"\\>\\<a href=results\\?d=%d target=\\\"$S\\\"\\>" r.result_num |
if !!html_mods then Printf.sprintf "\\<td class=\\\"sr\\\"\\>\\<a href=results\\?d=%d target=\\\"$S\\\"\\>" r.result_num |
1273 |
else Printf.sprintf "\\<a href=results\\?d=%d $S\\>" r.result_num; |
else Printf.sprintf "\\<a href=results\\?d=%d $S\\>" r.result_num; |
1274 |
end |
end |
1275 |
else "") |
else "") |
1276 |
|
|
1277 |
( shorten ( |
( shorten ( |
1278 |
let names = r.result_names in |
let names = r.result_names in |
1279 |
let names = if r.result_done then |
let names = if r.result_done then |
1281 |
let names = match r.result_comment with |
let names = match r.result_comment with |
1282 |
"" -> names |
"" -> names |
1283 |
| comment -> |
| comment -> |
1284 |
names @ ["COMMENT: " ^ comment] |
names @ ["COMMENT: " ^ comment] |
1285 |
in |
in |
1286 |
match names with |
match names with |
1287 |
[name] -> name |
[name] -> name |
1288 |
| _ -> |
| _ -> |
1289 |
let buf = Buffer.create 100 in |
let buf = Buffer.create 100 in |
1290 |
if o.conn_output = HTML then Buffer.add_string buf "\\<table\\>\n"; |
if o.conn_output = HTML then Buffer.add_string buf "\\<table\\>\n"; |
1291 |
List.iter (fun s -> |
List.iter (fun s -> |
1292 |
if o.conn_output = HTML then Buffer.add_string buf "\\<tr\\>"; |
if o.conn_output = HTML then Buffer.add_string buf "\\<tr\\>"; |
1293 |
Buffer.add_string buf s; |
Buffer.add_string buf s; |
1294 |
if o.conn_output = HTML then Buffer.add_string buf "\\</tr\\>"; |
if o.conn_output = HTML then Buffer.add_string buf "\\</tr\\>"; |
1295 |
) names; |
) names; |
1296 |
if o.conn_output = HTML then Buffer.add_string buf "\\</table\\>\n"; |
if o.conn_output = HTML then Buffer.add_string buf "\\</table\\>\n"; |
1297 |
|
|
1298 |
Buffer.contents buf |
Buffer.contents buf |
1299 |
) !!max_name_len) |
) !!max_name_len) |
1300 |
(if o.conn_output = HTML then |
(if o.conn_output = HTML then |
1301 |
begin |
begin |
1302 |
if !!html_mods then "\\</a\\>\\</td\\>" |
if !!html_mods then "\\</a\\>\\</td\\>" |
1303 |
else "\\</a href\\>" |
else "\\</a href\\>" |
1304 |
end |
end |
1305 |
else "" |
else "" |
1306 |
) |
) |
1307 |
); |
); |
1308 |
|
|
1309 |
|
|
1310 |
(let buf = Buffer.create 100 in |
(let buf = Buffer.create 100 in |
1311 |
|
|
1312 |
if use_html_mods o then Buffer.add_string buf "\\<td class=\\\"sr\\\"\\>"; |
if use_html_mods o then Buffer.add_string buf "\\<td class=\\\"sr\\\"\\>"; |
1313 |
|
|
1314 |
List.iter (fun t -> |
List.iter (fun t -> |
1315 |
Buffer.add_string buf (Printf.sprintf "%-3s " |
Buffer.add_string buf (Printf.sprintf "%-3s " |
1316 |
(if t.tag_name = Field_Availability then "" else |
(if t.tag_name = Field_Availability then "" else |
1322 |
)) |
)) |
1323 |
) r.result_tags; |
) r.result_tags; |
1324 |
Buffer.contents buf); |
Buffer.contents buf); |
1325 |
|
|
1326 |
( |
( |
1327 |
let uid = string_of_uids r.result_uids in |
let uid = string_of_uids r.result_uids in |
1328 |
if use_html_mods o then |
if use_html_mods o then |
1329 |
Printf.sprintf "\\<td class=\\\"sr\\\"\\>%s\\</td\\>" uid |
Printf.sprintf "\\<td class=\\\"sr\\\"\\>%s\\</td\\>" uid |
1330 |
else uid |
else uid |
1331 |
); |
); |
1332 |
|
|
1333 |
|] :: !files; |
|] :: !files; |
1334 |
end |
end |
1335 |
) results; |
) results; |
1337 |
if use_html_mods o then |
if use_html_mods o then |
1338 |
begin |
begin |
1339 |
|
|
1340 |
html_mods_table_header buf "resultsTable" "results" [ |
html_mods_table_header buf "resultsTable" "results" [ |
1341 |
( "1", "srh", "Number", "#" ) ; |
( "1", "srh", "Number", "#" ) ; |
1342 |
( "1", "srh ar", "Size", "Size" ) ; |
( "1", "srh ar", "Size", "Size" ) ; |
1343 |
( "0", "srh ar", "Availability", "A" ) ; |
( "0", "srh ar", "Availability", "A" ) ; |
1344 |
( "0", "srh", "Filename", "Name" ) ; |
( "0", "srh", "Filename", "Name" ) ; |
1345 |
( "0", "srh", "Tag", "Tag" ) ; |
( "0", "srh", "Tag", "Tag" ) ; |
1346 |
( "0", "srh", "MD4", "MD4" ) ]; |
( "0", "srh", "MD4", "MD4" ) ]; |
1347 |
|
|
1348 |
print_table_html_mods buf |
print_table_html_mods buf |
1349 |
(List.rev !files) |
(List.rev !files) |
1350 |
|
|
1351 |
end |
end |
1352 |
|
|
1353 |
else |
else |
1354 |
|
|
1355 |
print_table buf [| Align_Left; Align_Right; Align_Right; Align_Left; Align_Left; Align_Left|] |
print_table buf [| Align_Left; Align_Right; Align_Right; Align_Left; Align_Left; Align_Left|] |
1356 |
[| |
[| |
1357 |
"[ Num ]"; |
"[ Num ]"; |
1358 |
"Size"; |
"Size"; |
1360 |
"Names"; |
"Names"; |
1361 |
"Tags"; |
"Tags"; |
1362 |
"MD4"; |
"MD4"; |
1363 |
|] |
|] |
1364 |
|
|
1365 |
(List.rev !files); |
(List.rev !files); |
1366 |
Printf.bprintf buf "%d sources, total available %s\n" !nsources (size_of_int64 !totalsize) |
Printf.bprintf buf "%d sources, total available %s\n" !nsources (size_of_int64 !totalsize) |
1367 |
|
|
1368 |
|
|
1369 |
let print_search buf s o = |
let print_search buf s o = |
1370 |
let user = o.conn_user in |
let user = o.conn_user in |
1371 |
user.ui_last_search <- Some s; |
user.ui_last_search <- Some s; |
1372 |
user.ui_last_results <- []; |
user.ui_last_results <- []; |
1377 |
let results = Sort.list (fun (_, r1,_) (_, r2,_) -> |
let results = Sort.list (fun (_, r1,_) (_, r2,_) -> |
1378 |
r1.result_size > r2.result_size |
r1.result_size > r2.result_size |
1379 |
) !results in |
) !results in |
1380 |
|
|
1381 |
Printf.bprintf buf "Result of search %d\n" s.search_num; |
Printf.bprintf buf "Result of search %d\n" s.search_num; |
1382 |
Printf.bprintf buf "Reinitialising download selectors\n"; |
Printf.bprintf buf "Reinitialising download selectors\n"; |
1383 |
Printf.bprintf buf "%d results (%s)\n" s.search_nresults |
Printf.bprintf buf "%d results (%s)\n" s.search_nresults |
1384 |
(if s.search_waiting = 0 then "done" else |
(if s.search_waiting = 0 then "done" else |
1385 |
(string_of_int s.search_waiting) ^ " waiting"); |
(string_of_int s.search_waiting) ^ " waiting"); |
1386 |
|
|
1387 |
if o.conn_output != HTML then print_results s.search_time buf o results else |
if o.conn_output != HTML then print_results s.search_time buf o results else |
1388 |
begin |
begin |
1389 |
if !!html_checkbox_search_file_list then |
if !!html_checkbox_search_file_list then |
1390 |
print_search_html buf results o s.search_num |
print_search_html buf results o s.search_num |
1391 |
else |
else |
1392 |
old_print_search buf o results |
old_print_search buf o results |
1393 |
end |
end |
1394 |
|
|
1395 |
let browse_friends () = |
let browse_friends () = |
1396 |
List.iter (fun c -> client_browse c false) !!friends; |
List.iter (fun c -> client_browse c false) !!friends; |
1419 |
|
|
1420 |
networks_iter_all |
networks_iter_all |
1421 |
(fun n -> |
(fun n -> |
1422 |
if not (List.mem VirtualNetwork n.network_flags) then |
if not (List.mem VirtualNetwork n.network_flags) then |
1423 |
try |
try |
1424 |
let net_has e = if List.mem e n.network_flags then "yes" else "" in |
let net_has e = if List.mem e n.network_flags then "yes" else "" in |
1425 |
Printf.bprintf buf "\\<tr class=\\\"dl-%d\\\"\\>" (html_mods_cntr ()); |
Printf.bprintf buf "\\<tr class=\\\"dl-%d\\\"\\>" (html_mods_cntr ()); |
1426 |
html_mods_td buf [ |
html_mods_td buf [ |
1427 |
("", "sr br", n.network_name); |
("", "sr br", n.network_name); |
1440 |
html_mods_table_header buf "networkTable" "networkInfo" []; |
html_mods_table_header buf "networkTable" "networkInfo" []; |
1441 |
Printf.bprintf buf "\\<tr class=\\\"dl-%d\\\"\\>" (html_mods_cntr ()); |
Printf.bprintf buf "\\<tr class=\\\"dl-%d\\\"\\>" (html_mods_cntr ()); |
1442 |
html_mods_td buf [ |
html_mods_td buf [ |
1443 |
("", "sr br", |
("", "sr br", |
1444 |
"This table prints information about the capabilities of\nMLDonkey network modules, not the networks themselves"); ]; |
"This table prints information about the capabilities of\nMLDonkey network modules, not the networks themselves"); ]; |
1445 |
Printf.bprintf buf "\\</table\\>\\</div\\>\\</div\\>\n" |
Printf.bprintf buf "\\</table\\>\\</div\\>\\</div\\>\n" |
1446 |
end |
end |