340 |
), "<num> :\t\t\t\tview client (use arg 'all' for all clients)"; |
), "<num> :\t\t\t\tview client (use arg 'all' for all clients)"; |
341 |
|
|
342 |
"version", Arg_none (fun o -> |
"version", Arg_none (fun o -> |
343 |
if use_html_mods o then Printf.sprintf "\\<P\\>" ^ |
let buf = o.conn_buf in |
344 |
CommonGlobals.version () else CommonGlobals.version () |
let version = CommonGlobals.version () in |
345 |
|
if o.conn_output = HTML then |
346 |
|
begin |
347 |
|
Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>"; |
348 |
|
html_mods_table_header buf "versionTable" "results" []; |
349 |
|
Printf.bprintf buf "\\<tr\\>"; |
350 |
|
html_mods_td buf [ ("", "srh", version); ]; |
351 |
|
Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>"; |
352 |
|
end |
353 |
|
else |
354 |
|
Printf.bprintf buf "%s" version; |
355 |
|
"" |
356 |
), ":\t\t\t\tprint mldonkey version"; |
), ":\t\t\t\tprint mldonkey version"; |
357 |
|
|
358 |
"buildinfo", Arg_none (fun o -> |
"buildinfo", Arg_none (fun o -> |
359 |
if use_html_mods o then Printf.sprintf "\\<P\\>" ^ |
let buf = o.conn_buf in |
360 |
CommonGlobals.buildinfo () else CommonGlobals.buildinfo () |
let buildinfo = CommonGlobals.buildinfo () in |
361 |
|
if o.conn_output = HTML then |
362 |
|
begin |
363 |
|
Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>"; |
364 |
|
html_mods_table_header buf "versionTable" "results" []; |
365 |
|
Printf.bprintf buf "\\<tr class=\\\"dl-1\\\"\\>"; |
366 |
|
html_mods_td buf [ ("", "sr", Str.global_replace (Str.regexp "\n") "\\<br\\>" buildinfo); ]; |
367 |
|
Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>"; |
368 |
|
end |
369 |
|
else |
370 |
|
Printf.bprintf buf "%s" buildinfo; |
371 |
|
"" |
372 |
), ":\t\t\t\tprint mldonkey core build information"; |
), ":\t\t\t\tprint mldonkey core build information"; |
373 |
|
|
374 |
"activity", Arg_one (fun arg o -> |
"activity", Arg_one (fun arg o -> |
2310 |
Printf.sprintf (_b "Download %d renamed to %s") num new_name |
Printf.sprintf (_b "Download %d renamed to %s") num new_name |
2311 |
with _ -> Printf.sprintf (_b "No file number %d") num |
with _ -> Printf.sprintf (_b "No file number %d") num |
2312 |
), "<num> \"<new name>\" :\t\tchange name of download <num> to <new name>"; |
), "<num> \"<new name>\" :\t\tchange name of download <num> to <new name>"; |
2313 |
|
|
2314 |
|
|
2315 |
"dllink", Arg_multiple (fun args o -> |
"dllink", Arg_multiple (fun args o -> |
2316 |
if !verbose then lprintf "dllink\n"; |
if !verbose then lprintf "dllink\n"; |
2317 |
let buf = o.conn_buf in |
let buf = o.conn_buf in |
2318 |
let query_networks url = |
let query_networks url = |
2319 |
if not (networks_iter_until_true |
if not (networks_iter_until_true |
2320 |
(fun n -> |
(fun n -> |
2321 |
try |
try |
2325 |
(Printexc2.to_string e) (n.network_name); |
(Printexc2.to_string e) (n.network_name); |
2326 |
false |
false |
2327 |
)) then |
)) then |
2328 |
_s "Unable to match URL" |
let output = (if o.conn_output = HTML then begin |
2329 |
|
let buf = Buffer.create 100 in |
2330 |
|
Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>"; |
2331 |
|
html_mods_table_header buf "dllinkTable" "results" []; |
2332 |
|
Printf.bprintf buf "\\<tr\\>"; |
2333 |
|
html_mods_td buf [ ("", "srh", "Unable to match URL"); ]; |
2334 |
|
Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-1\\\"\\>"; |
2335 |
|
html_mods_td buf [ ("", "sr", url); ]; |
2336 |
|
Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>"; |
2337 |
|
Buffer.contents buf |
2338 |
|
end |
2339 |
|
else begin |
2340 |
|
Printf.sprintf "Unable to match URL : %s" url |
2341 |
|
end) in |
2342 |
|
_s output |
2343 |
else |
else |
2344 |
_s "done" |
let output = (if o.conn_output = HTML then begin |
2345 |
|
let buf = Buffer.create 100 in |
2346 |
|
Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>"; |
2347 |
|
html_mods_table_header buf "dllinkTable" "results" []; |
2348 |
|
Printf.bprintf buf "\\<tr\\>"; |
2349 |
|
html_mods_td buf [ ("", "srh", "Added link"); ]; |
2350 |
|
Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-1\\\"\\>"; |
2351 |
|
html_mods_td buf [ ("", "sr", url); ]; |
2352 |
|
Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>"; |
2353 |
|
Buffer.contents buf |
2354 |
|
end |
2355 |
|
else begin |
2356 |
|
Printf.sprintf "Added link : %s" url |
2357 |
|
end) in |
2358 |
|
_s output |
2359 |
in |
in |
2360 |
|
|
2361 |
let url = String2.unsplit args ' ' in |
let url = String2.unsplit args ' ' in |
2362 |
if (String2.starts_with url "http") then ( |
if (String2.starts_with url "http") then ( |
2363 |
let u = Url.of_string url in |
let u = Url.of_string url in |
2370 |
H.req_user_agent = |
H.req_user_agent = |
2371 |
Printf.sprintf "MLdonkey/%s" Autoconf.current_version; |
Printf.sprintf "MLdonkey/%s" Autoconf.current_version; |
2372 |
} in |
} in |
2373 |
H.whead r |
H.whead r |
2374 |
(fun headers -> |
(fun headers -> |
2375 |
(* Combine the list of header fields into one string *) |
(* Combine the list of header fields into one string *) |
2376 |
let concat_headers = |
let concat_headers = |
2377 |
(List.fold_right (fun (n, c) t -> n ^ ": " ^ c ^ "\n" ^ t) headers "") |
(List.fold_right (fun (n, c) t -> n ^ ": " ^ c ^ "\n" ^ t) headers "") |
2378 |
in |
in |
2379 |
ignore (query_networks concat_headers) |
ignore (query_networks concat_headers) |
2380 |
); |
); |
2381 |
_s "Parsing HTTP url..." |
let output = (if o.conn_output = HTML then begin |
2382 |
|
let buf = Buffer.create 100 in |
2383 |
|
Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>"; |
2384 |
|
html_mods_table_header buf "dllinkTable" "results" []; |
2385 |
|
Printf.bprintf buf "\\<tr\\>"; |
2386 |
|
html_mods_td buf [ ("", "srh", "Parsing HTTP url"); ]; |
2387 |
|
Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-1\\\"\\>"; |
2388 |
|
html_mods_td buf [ ("", "sr", url); ]; |
2389 |
|
Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>"; |
2390 |
|
Buffer.contents buf |
2391 |
|
end |
2392 |
|
else begin |
2393 |
|
Printf.sprintf "Parsing HTTP url : %s" url |
2394 |
|
end) in |
2395 |
|
_s output |
2396 |
) |
) |
2397 |
else |
else |
2398 |
query_networks url |
query_networks url |
2399 |
), "<link> :\t\t\t\tdownload ed2k, sig2dat, torrent or other link"; |
), "<link> :\t\t\t\tdownload ed2k, sig2dat, torrent or other link"; |
2400 |
|
|
2401 |
"dllinks", Arg_one (fun arg o -> |
"dllinks", Arg_one (fun arg o -> |
2402 |
let buf = o.conn_buf in |
let buf = o.conn_buf in |
2403 |
|
|
2404 |
let file = File.to_string arg in |
let file = File.to_string arg in |
2405 |
let lines = String2.split_simplify file '\n' in |
let lines = String2.split_simplify file '\n' in |
2406 |
List.iter (fun line -> |
List.iter (fun line -> |
2407 |
ignore (networks_iter_until_true (fun n -> |
ignore (networks_iter_until_true (fun n -> |
2408 |
network_parse_url n line)) |
network_parse_url n line)) |
2409 |
) lines; |
) lines; |
2410 |
_s "done" |
let output = (if o.conn_output = HTML then begin |
2411 |
|
let buf = Buffer.create 100 in |
2412 |
|
Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>"; |
2413 |
|
html_mods_table_header buf "dllinksTable" "results" []; |
2414 |
|
Printf.bprintf buf "\\<tr\\>"; |
2415 |
|
html_mods_td buf [ ("", "srh", "Added links"); ]; |
2416 |
|
Printf.bprintf buf "\\</tr\\>"; |
2417 |
|
List.iter (fun line -> |
2418 |
|
Printf.bprintf buf "\\<tr class=\\\"dl-1\\\"\\>"; |
2419 |
|
html_mods_td buf [ ("", "sr", line); ]; |
2420 |
|
Printf.bprintf buf "\\</tr\\>\\"; |
2421 |
|
) lines; |
2422 |
|
Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>"; |
2423 |
|
Buffer.contents buf |
2424 |
|
end |
2425 |
|
else begin |
2426 |
|
Printf.sprintf "done" |
2427 |
|
end) in |
2428 |
|
_s output |
2429 |
), "<file> :\t\t\t\tdownload all the links contained in the file"; |
), "<file> :\t\t\t\tdownload all the links contained in the file"; |
2430 |
|
|
2431 |
] |
] |
2432 |
|
|
2433 |
|
|
2434 |
|
|
2435 |
(*************************************************************************) |
(*************************************************************************) |
2436 |
(* *) |
(* *) |
2437 |
(* Driver/Xpert *) |
(* Driver/Xpert *) |
2579 |
), ":\t\t\tselect html_mods_style <#>"; |
), ":\t\t\tselect html_mods_style <#>"; |
2580 |
|
|
2581 |
"rss", Arg_none (fun o -> |
"rss", Arg_none (fun o -> |
|
|
|
2582 |
let buf = o.conn_buf in |
let buf = o.conn_buf in |
2583 |
let module CW = CommonWeb in |
let module CW = CommonWeb in |
2584 |
Hashtbl.iter (fun url feed -> |
Hashtbl.iter (fun url feed -> |
|
(if o.conn_output = HTML then begin |
|
|
Printf.bprintf buf "\\<br\\>\\<br\\>\\<table class=\\\"results\\\"\\>\\<tr\\>\n"; |
|
|
Printf.bprintf buf "\\<td class=\\\"bu bbig\\\" title=\\\"%s: " url; |
|
|
Printf.bprintf buf "loaded %d hours ago\\\"\\>\n" |
|
|
end |
|
|
else begin |
|
|
Printf.bprintf buf "%s:\n" url; |
|
|
Printf.bprintf buf " loaded %d hours ago\n" |
|
|
end) |
|
|
(feed.CW.rss_date / 3600); |
|
2585 |
let r = feed.CW.rss_value in |
let r = feed.CW.rss_value in |
2586 |
if o.conn_output = HTML then begin |
if o.conn_output = HTML then begin |
2587 |
Printf.bprintf buf "\\<b\\>%s\\</b\\>\n" r.Rss.ch_title; |
Printf.bprintf buf "\\</pre\\>\\<div class=\\\"cs\\\"\\>"; |
2588 |
Printf.bprintf buf "\\</td\\>\\</tr\\>" |
html_mods_table_header buf "rssTable" "results" []; |
2589 |
end |
Printf.bprintf buf "\\<tr\\>"; |
2590 |
else |
html_mods_td buf [ |
2591 |
Printf.bprintf buf " title: %s\n" r.Rss.ch_title; |
(r.Rss.ch_title ^ " : " ^ url ^ (Printf.sprintf ", loaded %d hours ago" (feed.CW.rss_date / 3600)), "srh", r.Rss.ch_title); ]; |
2592 |
|
Printf.bprintf buf "\\</tr\\>" |
2593 |
|
end |
2594 |
|
else begin |
2595 |
|
Printf.bprintf buf "%s:\n" url; |
2596 |
|
Printf.bprintf buf " loaded %d hours ago\n" (feed.CW.rss_date / 3600); |
2597 |
|
Printf.bprintf buf " title: %s\n" r.Rss.ch_title; |
2598 |
|
end; |
2599 |
|
html_mods_cntr_init (); |
2600 |
List.iter (fun item -> |
List.iter (fun item -> |
2601 |
match item.Rss.item_title, item.Rss.item_link with |
match item.Rss.item_title, item.Rss.item_link with |
2602 |
None, _ |
None, _ |
2603 |
| _, None -> () |
| _, None -> () |
2604 |
| Some title, Some link -> |
| Some title, Some link -> |
2605 |
if o.conn_output = HTML then begin |
if o.conn_output = HTML then begin |
2606 |
Printf.bprintf buf "\\<tr class=\\\"dl-1\\\"\\>\\<td class=\\\"sr\\\"\\>"; |
Printf.bprintf buf "\\<tr class=\\\"dl-%d\\\"\\>" (html_mods_cntr ()); |
2607 |
Printf.bprintf buf "\\<a href=\\\"submit?q=dllink+%s\\\"\\ title=\\\"%s\\\"\\>%s\\</a\\>\n" (Url.encode link) link title; |
html_mods_td buf [ |
2608 |
Printf.bprintf buf "\\</td\\>\\</tr\\>" |
(title, "sr", "\\<a href=\\\"submit?q=dllink+" ^ (Url.encode link) ^ "\\\"\\ title=\\\"" ^ link ^ "\\\"\\>" ^ title ^ "\\</a\\>"); ]; |
2609 |
|
Printf.bprintf buf "\\</tr\\>" |
2610 |
end |
end |
2611 |
else begin |
else begin |
2612 |
Printf.bprintf buf " %s\n" title; |
Printf.bprintf buf " %s\n" title; |
2614 |
end |
end |
2615 |
) r.Rss.ch_items; |
) r.Rss.ch_items; |
2616 |
if o.conn_output = HTML then |
if o.conn_output = HTML then |
2617 |
Printf.bprintf buf "\\</table\\>"; |
Printf.bprintf buf "\\</table\\>\\</div\\>\\</div\\>\\<pre\\>"; |
2618 |
) CW.rss_feeds; |
) CW.rss_feeds; |
2619 |
"" |
"" |
2620 |
|
|
2646 |
|
|
2647 |
), "<theme>:\t\t\tselect html_theme"; |
), "<theme>:\t\t\tselect html_theme"; |
2648 |
|
|
2649 |
"mem_stats", Arg_one (fun level o -> |
"mem_stats", Arg_one (fun level o -> |
2650 |
let buf = o.conn_buf in |
let buf = o.conn_buf in |
2651 |
Heap.print_memstats (int_of_string level) buf; |
Heap.print_memstats (int_of_string level) buf |
2652 |
|
(if o.conn_output = HTML then true else false); |
2653 |
"" |
"" |
2654 |
), ":\t\t\t\tprint memory stats"; |
), ":\t\t\t\tprint memory stats"; |
2655 |
|
|