18 |
*) |
*) |
19 |
|
|
20 |
open Int64ops |
open Int64ops |
|
open AnyEndian |
|
|
open LittleEndian |
|
21 |
open Printf2 |
open Printf2 |
22 |
open Options |
open Options |
|
open BasicSocket (* last_time *) |
|
|
open GuiTypes |
|
|
open CommonOptions |
|
23 |
open CommonTypes |
open CommonTypes |
24 |
|
open CommonOptions |
25 |
open CommonGlobals |
open CommonGlobals |
26 |
open CommonNetwork |
open CommonNetwork |
|
open CommonMessages |
|
27 |
open CommonInteractive |
open CommonInteractive |
28 |
|
open CommonStats |
29 |
|
|
30 |
open DonkeyOptions |
open DonkeyOptions |
31 |
open DonkeyTypes |
open DonkeyTypes |
32 |
open DonkeyGlobals |
open DonkeyGlobals |
33 |
open DonkeyComplexOptions |
open DonkeyComplexOptions |
34 |
|
|
35 |
|
let start_session = ref (BasicSocket.last_time ()) |
36 |
|
|
37 |
let brand_to_int b = |
let stats_array = Array.init brand_count (fun _ -> |
38 |
match b with |
{ dummy_stats with brand_seen = 0 } |
|
Brand_unknown -> 0 |
|
|
| Brand_edonkey -> 1 |
|
|
| Brand_mldonkey1 -> 2 |
|
|
| Brand_mldonkey2 -> 3 |
|
|
| Brand_overnet -> 4 |
|
|
| Brand_newemule -> 5 |
|
|
| Brand_server -> 6 |
|
|
| Brand_mldonkey3 -> 7 |
|
|
| Brand_cdonkey -> 8 |
|
|
| Brand_lmule -> 9 |
|
|
| Brand_shareaza -> 10 |
|
|
| Brand_amule -> 11 |
|
|
| Brand_lphant -> 12 |
|
|
| Brand_emuleplus -> 13 |
|
|
| Brand_hydranode -> 14 |
|
|
|
|
|
let brand_of_int b = |
|
|
match b with |
|
|
0 -> Brand_unknown |
|
|
| 1 -> Brand_edonkey |
|
|
| 2 -> Brand_mldonkey1 |
|
|
| 3 -> Brand_mldonkey2 |
|
|
| 4 -> Brand_overnet |
|
|
| 5 -> Brand_newemule |
|
|
| 6 -> Brand_server |
|
|
| 7 -> Brand_mldonkey3 |
|
|
| 8 -> Brand_cdonkey |
|
|
| 9 -> Brand_lmule |
|
|
| 10 -> Brand_shareaza |
|
|
| 11 -> Brand_amule |
|
|
| 12 -> Brand_lphant |
|
|
| 13 -> Brand_emuleplus |
|
|
| 14 -> Brand_hydranode |
|
|
| _ -> raise Not_found |
|
|
|
|
|
let gbrand_to_string b = |
|
|
match b with |
|
|
Brand_unknown -> "unk" |
|
|
| Brand_edonkey -> "eDK" |
|
|
| Brand_cdonkey -> "cDK" |
|
|
| Brand_mldonkey1 -> "oML" |
|
|
| Brand_mldonkey2 -> "nML" |
|
|
| Brand_mldonkey3 -> "tML" |
|
|
| Brand_overnet -> "OVR" |
|
|
| Brand_newemule -> "eMU" |
|
|
| Brand_lmule -> "xMU" |
|
|
| Brand_shareaza -> "sZA" |
|
|
| Brand_server -> "SER" |
|
|
| Brand_amule -> "aMU" |
|
|
| Brand_lphant -> "lPH" |
|
|
| Brand_emuleplus -> "eM+" |
|
|
| Brand_hydranode -> "Hyd" |
|
|
|
|
|
let brand_mod_to_int b = |
|
|
match b with |
|
|
Brand_mod_unknown -> 0 |
|
|
| Brand_mod_extasy -> 1 |
|
|
| Brand_mod_hunter -> 2 |
|
|
| Brand_mod_sivka -> 3 |
|
|
| Brand_mod_ice -> 4 |
|
|
| Brand_mod_plus -> 5 |
|
|
| Brand_mod_lsd -> 6 |
|
|
| Brand_mod_maella -> 7 |
|
|
| Brand_mod_pille -> 8 |
|
|
| Brand_mod_morphkad -> 9 |
|
|
| Brand_mod_efmod -> 10 |
|
|
| Brand_mod_xtreme -> 11 |
|
|
| Brand_mod_bionic -> 12 |
|
|
| Brand_mod_pawcio -> 13 |
|
|
| Brand_mod_zzul -> 14 |
|
|
| Brand_mod_blackhand -> 15 |
|
|
| Brand_mod_lovelace -> 16 |
|
|
| Brand_mod_morphnext -> 17 |
|
|
| Brand_mod_fincan -> 18 |
|
|
| Brand_mod_ewombat -> 19 |
|
|
| Brand_mod_morph -> 20 |
|
|
| Brand_mod_mortillo -> 21 |
|
|
| Brand_mod_lh -> 22 |
|
|
| Brand_mod_emulespana -> 23 |
|
|
| Brand_mod_blackrat -> 24 |
|
|
| Brand_mod_enkeydev -> 25 |
|
|
| Brand_mod_gnaddelwarz -> 26 |
|
|
| Brand_mod_phoenixkad -> 27 |
|
|
| Brand_mod_koizo -> 28 |
|
|
| Brand_mod_ed2kfiles -> 29 |
|
|
| Brand_mod_athlazan -> 30 |
|
|
| Brand_mod_cryptum -> 31 |
|
|
| Brand_mod_lamerzchoice -> 32 |
|
|
| Brand_mod_notdead -> 33 |
|
|
| Brand_mod_peace -> 34 |
|
|
| Brand_mod_goldicryptum -> 35 |
|
|
| Brand_mod_eastshare -> 36 |
|
|
| Brand_mod_mfck -> 37 |
|
|
| Brand_mod_echanblard -> 38 |
|
|
| Brand_mod_sp4rk -> 39 |
|
|
| Brand_mod_powermule -> 40 |
|
|
| Brand_mod_bloodymad -> 41 |
|
|
| Brand_mod_roman2k -> 42 |
|
|
| Brand_mod_gammaoh -> 43 |
|
|
| Brand_mod_elfenwombat -> 44 |
|
|
| Brand_mod_o2 -> 45 |
|
|
| Brand_mod_dm -> 46 |
|
|
| Brand_mod_sfiom -> 47 |
|
|
| Brand_mod_magic_elseve -> 48 |
|
|
| Brand_mod_schlumpmule -> 49 |
|
|
| Brand_mod_lc -> 50 |
|
|
| Brand_mod_noamson -> 51 |
|
|
| Brand_mod_stormit -> 52 |
|
|
| Brand_mod_omax -> 53 |
|
|
| Brand_mod_mison -> 54 |
|
|
| Brand_mod_phoenix -> 55 |
|
|
| Brand_mod_spiders -> 56 |
|
|
| Brand_mod_iberica -> 57 |
|
|
| Brand_mod_mortimer -> 58 |
|
|
| Brand_mod_stonehenge -> 59 |
|
|
| Brand_mod_xlillo -> 60 |
|
|
| Brand_mod_imperator -> 61 |
|
|
| Brand_mod_raziboom -> 62 |
|
|
| Brand_mod_khaos -> 63 |
|
|
| Brand_mod_hardmule -> 64 |
|
|
| Brand_mod_sc -> 65 |
|
|
| Brand_mod_cy4n1d -> 66 |
|
|
| Brand_mod_dmx -> 67 |
|
|
| Brand_mod_ketamine -> 68 |
|
|
| Brand_mod_blackmule -> 69 |
|
|
| Brand_mod_morphxt -> 70 |
|
|
| Brand_mod_ngdonkey -> 71 |
|
|
| Brand_mod_hawkstar -> 72 |
|
|
| Brand_mod_neomule -> 73 |
|
|
| Brand_mod_cyrex -> 74 |
|
|
| Brand_mod_aldo -> 75 |
|
|
| Brand_mod_emulede -> 76 |
|
|
| Brand_mod_zx -> 77 |
|
|
| Brand_mod_ibericaxt -> 78 |
|
|
| Brand_mod_candymule -> 79 |
|
|
| Brand_mod_ackronic -> 80 |
|
|
| Brand_mod_rappis -> 81 |
|
|
| Brand_mod_overdose -> 82 |
|
|
| Brand_mod_hebmule -> 83 |
|
|
| Brand_mod_senfei -> 84 |
|
|
| Brand_mod_spoofmod -> 85 |
|
|
| Brand_mod_fusspilz -> 86 |
|
|
| Brand_mod_rocket -> 87 |
|
|
| Brand_mod_warezfaw -> 88 |
|
|
| Brand_mod_emusicmule -> 89 |
|
|
| Brand_mod_aideadsl -> 90 |
|
|
| Brand_mod_epo -> 91 |
|
|
| Brand_mod_kalitsch -> 92 |
|
|
| Brand_mod_raynz -> 93 |
|
|
| Brand_mod_serverclient -> 94 |
|
|
| Brand_mod_bl4ckbird -> 95 |
|
|
| Brand_mod_bl4ckf0x -> 96 |
|
|
| Brand_mod_rt -> 97 |
|
|
| Brand_mod_airionix -> 98 |
|
|
| Brand_mod_ionix -> 99 |
|
|
| Brand_mod_tornado -> 100 |
|
|
| Brand_mod_antifaker -> 101 |
|
|
| Brand_mod_netf -> 102 |
|
|
| Brand_mod_nextemf -> 103 |
|
|
| Brand_mod_proemule -> 104 |
|
|
| Brand_mod_szemule -> 105 |
|
|
| Brand_mod_darkmule -> 106 |
|
|
| Brand_mod_miragemod -> 107 |
|
|
| Brand_mod_nextevolution -> 108 |
|
|
| Brand_mod_pootzgrila -> 109 |
|
|
| Brand_mod_freeangel -> 110 |
|
|
| Brand_mod_enos -> 111 |
|
|
| Brand_mod_webys -> 112 |
|
|
|
|
|
let brand_mod_of_int b = |
|
|
match b with |
|
|
0 -> Brand_mod_unknown |
|
|
| 1 -> Brand_mod_extasy |
|
|
| 2 -> Brand_mod_hunter |
|
|
| 3 -> Brand_mod_sivka |
|
|
| 4 -> Brand_mod_ice |
|
|
| 5 -> Brand_mod_plus |
|
|
| 6 -> Brand_mod_lsd |
|
|
| 7 -> Brand_mod_maella |
|
|
| 8 -> Brand_mod_pille |
|
|
| 9 -> Brand_mod_morphkad |
|
|
| 10 -> Brand_mod_efmod |
|
|
| 11 -> Brand_mod_xtreme |
|
|
| 12 -> Brand_mod_bionic |
|
|
| 13 -> Brand_mod_pawcio |
|
|
| 14 -> Brand_mod_zzul |
|
|
| 15 -> Brand_mod_blackhand |
|
|
| 16 -> Brand_mod_lovelace |
|
|
| 17 -> Brand_mod_morphnext |
|
|
| 18 -> Brand_mod_fincan |
|
|
| 19 -> Brand_mod_ewombat |
|
|
| 20 -> Brand_mod_morph |
|
|
| 21 -> Brand_mod_mortillo |
|
|
| 22 -> Brand_mod_lh |
|
|
| 23 -> Brand_mod_emulespana |
|
|
| 24 -> Brand_mod_blackrat |
|
|
| 25 -> Brand_mod_enkeydev |
|
|
| 26 -> Brand_mod_gnaddelwarz |
|
|
| 27 -> Brand_mod_phoenixkad |
|
|
| 28 -> Brand_mod_koizo |
|
|
| 29 -> Brand_mod_ed2kfiles |
|
|
| 30 -> Brand_mod_athlazan |
|
|
| 31 -> Brand_mod_cryptum |
|
|
| 32 -> Brand_mod_lamerzchoice |
|
|
| 33 -> Brand_mod_notdead |
|
|
| 34 -> Brand_mod_peace |
|
|
| 35 -> Brand_mod_goldicryptum |
|
|
| 36 -> Brand_mod_eastshare |
|
|
| 37 -> Brand_mod_mfck |
|
|
| 38 -> Brand_mod_echanblard |
|
|
| 39 -> Brand_mod_sp4rk |
|
|
| 40 -> Brand_mod_powermule |
|
|
| 41 -> Brand_mod_bloodymad |
|
|
| 42 -> Brand_mod_roman2k |
|
|
| 43 -> Brand_mod_gammaoh |
|
|
| 44 -> Brand_mod_elfenwombat |
|
|
| 45 -> Brand_mod_o2 |
|
|
| 46 -> Brand_mod_dm |
|
|
| 47 -> Brand_mod_sfiom |
|
|
| 48 -> Brand_mod_magic_elseve |
|
|
| 49 -> Brand_mod_schlumpmule |
|
|
| 50 -> Brand_mod_lc |
|
|
| 51 -> Brand_mod_noamson |
|
|
| 52 -> Brand_mod_stormit |
|
|
| 53 -> Brand_mod_omax |
|
|
| 54 -> Brand_mod_mison |
|
|
| 55 -> Brand_mod_phoenix |
|
|
| 56 -> Brand_mod_spiders |
|
|
| 57 -> Brand_mod_iberica |
|
|
| 58 -> Brand_mod_mortimer |
|
|
| 59 -> Brand_mod_stonehenge |
|
|
| 60 -> Brand_mod_xlillo |
|
|
| 61 -> Brand_mod_imperator |
|
|
| 62 -> Brand_mod_raziboom |
|
|
| 63 -> Brand_mod_khaos |
|
|
| 64 -> Brand_mod_hardmule |
|
|
| 65 -> Brand_mod_sc |
|
|
| 66 -> Brand_mod_cy4n1d |
|
|
| 67 -> Brand_mod_dmx |
|
|
| 68 -> Brand_mod_ketamine |
|
|
| 69 -> Brand_mod_blackmule |
|
|
| 70 -> Brand_mod_morphxt |
|
|
| 71 -> Brand_mod_ngdonkey |
|
|
| 72 -> Brand_mod_hawkstar |
|
|
| 73 -> Brand_mod_neomule |
|
|
| 74 -> Brand_mod_cyrex |
|
|
| 75 -> Brand_mod_aldo |
|
|
| 76 -> Brand_mod_emulede |
|
|
| 77 -> Brand_mod_zx |
|
|
| 78 -> Brand_mod_ibericaxt |
|
|
| 79 -> Brand_mod_candymule |
|
|
| 80 -> Brand_mod_ackronic |
|
|
| 81 -> Brand_mod_rappis |
|
|
| 82 -> Brand_mod_overdose |
|
|
| 83 -> Brand_mod_hebmule |
|
|
| 84 -> Brand_mod_senfei |
|
|
| 85 -> Brand_mod_spoofmod |
|
|
| 86 -> Brand_mod_fusspilz |
|
|
| 87 -> Brand_mod_rocket |
|
|
| 88 -> Brand_mod_warezfaw |
|
|
| 89 -> Brand_mod_emusicmule |
|
|
| 90 -> Brand_mod_aideadsl |
|
|
| 91 -> Brand_mod_epo |
|
|
| 92 -> Brand_mod_kalitsch |
|
|
| 93 -> Brand_mod_raynz |
|
|
| 94 -> Brand_mod_serverclient |
|
|
| 95 -> Brand_mod_bl4ckbird |
|
|
| 96 -> Brand_mod_bl4ckf0x |
|
|
| 97 -> Brand_mod_rt |
|
|
| 98 -> Brand_mod_airionix |
|
|
| 99 -> Brand_mod_ionix |
|
|
| 100 -> Brand_mod_tornado |
|
|
| 101 -> Brand_mod_antifaker |
|
|
| 102 -> Brand_mod_netf |
|
|
| 103 -> Brand_mod_nextemf |
|
|
| 104 -> Brand_mod_proemule |
|
|
| 105 -> Brand_mod_szemule |
|
|
| 106 -> Brand_mod_darkmule |
|
|
| 107 -> Brand_mod_miragemod |
|
|
| 108 -> Brand_mod_nextevolution |
|
|
| 109 -> Brand_mod_pootzgrila |
|
|
| 110 -> Brand_mod_freeangel |
|
|
| 111 -> Brand_mod_enos |
|
|
| 112 -> Brand_mod_webys |
|
|
| _ -> raise Not_found |
|
|
|
|
|
let gbrand_mod_to_string b = |
|
|
match b with |
|
|
Brand_mod_unknown -> "" |
|
|
| Brand_mod_extasy -> "ext" |
|
|
| Brand_mod_hunter -> "hun" |
|
|
| Brand_mod_sivka -> "siv" |
|
|
| Brand_mod_ice -> "ice" |
|
|
| Brand_mod_plus -> "plu" |
|
|
| Brand_mod_lsd -> "lsd" |
|
|
| Brand_mod_maella -> "mae" |
|
|
| Brand_mod_pille -> "pil" |
|
|
| Brand_mod_morphkad -> "mo1" |
|
|
| Brand_mod_efmod -> "efm" |
|
|
| Brand_mod_xtreme -> "xtr" |
|
|
| Brand_mod_bionic -> "bio" |
|
|
| Brand_mod_pawcio -> "paw" |
|
|
| Brand_mod_zzul -> "zzu" |
|
|
| Brand_mod_blackhand -> "bla" |
|
|
| Brand_mod_lovelace -> "lov" |
|
|
| Brand_mod_morphnext -> "mo2" |
|
|
| Brand_mod_fincan -> "fin" |
|
|
| Brand_mod_ewombat -> "ewo" |
|
|
| Brand_mod_morph -> "mo3" |
|
|
| Brand_mod_mortillo -> "mot" |
|
|
| Brand_mod_lh -> "lh" |
|
|
| Brand_mod_emulespana -> "esp" |
|
|
| Brand_mod_blackrat -> "blr" |
|
|
| Brand_mod_enkeydev -> "ekd" |
|
|
| Brand_mod_gnaddelwarz -> "gna" |
|
|
| Brand_mod_phoenixkad -> "pkd" |
|
|
| Brand_mod_koizo -> "koi" |
|
|
| Brand_mod_ed2kfiles -> "edf" |
|
|
| Brand_mod_athlazan -> "ath" |
|
|
| Brand_mod_cryptum -> "cry" |
|
|
| Brand_mod_lamerzchoice -> "lam" |
|
|
| Brand_mod_notdead -> "nod" |
|
|
| Brand_mod_peace -> "pea" |
|
|
| Brand_mod_goldicryptum -> "gcr" |
|
|
| Brand_mod_eastshare -> "eas" |
|
|
| Brand_mod_mfck -> "mfc" |
|
|
| Brand_mod_echanblard -> "ech" |
|
|
| Brand_mod_sp4rk -> "sp4" |
|
|
| Brand_mod_powermule -> "pow" |
|
|
| Brand_mod_bloodymad -> "blo" |
|
|
| Brand_mod_roman2k -> "rom" |
|
|
| Brand_mod_gammaoh -> "gam" |
|
|
| Brand_mod_elfenwombat -> "elf" |
|
|
| Brand_mod_o2 -> "o2" |
|
|
| Brand_mod_dm -> "DM" |
|
|
| Brand_mod_sfiom -> "SFI" |
|
|
| Brand_mod_magic_elseve -> "MEl" |
|
|
| Brand_mod_schlumpmule -> "sch" |
|
|
| Brand_mod_lc -> "LC" |
|
|
| Brand_mod_noamson -> "NoS" |
|
|
| Brand_mod_stormit -> "Sto" |
|
|
| Brand_mod_omax -> "OMX" |
|
|
| Brand_mod_mison -> "Mis" |
|
|
| Brand_mod_phoenix -> "pPho" |
|
|
| Brand_mod_spiders -> "spi" |
|
|
| Brand_mod_iberica -> "Ib" |
|
|
| Brand_mod_mortimer -> "mor" |
|
|
| Brand_mod_stonehenge -> "sto" |
|
|
| Brand_mod_xlillo -> "Xli" |
|
|
| Brand_mod_imperator -> "Imp" |
|
|
| Brand_mod_raziboom -> "Raz" |
|
|
| Brand_mod_khaos -> "Kha" |
|
|
| Brand_mod_hardmule -> "Har" |
|
|
| Brand_mod_sc -> "SC" |
|
|
| Brand_mod_cy4n1d -> "Cy4" |
|
|
| Brand_mod_dmx -> "DMX" |
|
|
| Brand_mod_ketamine -> "Ket" |
|
|
| Brand_mod_blackmule -> "blm" |
|
|
| Brand_mod_morphxt -> "Mxt" |
|
|
| Brand_mod_ngdonkey -> "ngd" |
|
|
| Brand_mod_hawkstar -> "haw" |
|
|
| Brand_mod_neomule -> "neo" |
|
|
| Brand_mod_cyrex -> "cyr" |
|
|
| Brand_mod_aldo -> "ald" |
|
|
| Brand_mod_emulede -> "ede" |
|
|
| Brand_mod_zx -> "zx" |
|
|
| Brand_mod_ibericaxt -> "iBx" |
|
|
| Brand_mod_candymule -> "can" |
|
|
| Brand_mod_ackronic -> "ack" |
|
|
| Brand_mod_rappis -> "rap" |
|
|
| Brand_mod_overdose -> "ove" |
|
|
| Brand_mod_hebmule -> "heb" |
|
|
| Brand_mod_senfei -> "sen" |
|
|
| Brand_mod_spoofmod -> "spo" |
|
|
| Brand_mod_fusspilz -> "fus" |
|
|
| Brand_mod_rocket -> "roc" |
|
|
| Brand_mod_warezfaw -> "war" |
|
|
| Brand_mod_emusicmule -> "emm" |
|
|
| Brand_mod_aideadsl -> "aid" |
|
|
| Brand_mod_epo -> "epo" |
|
|
| Brand_mod_kalitsch -> "kal" |
|
|
| Brand_mod_raynz -> "ray" |
|
|
| Brand_mod_serverclient -> "sc" |
|
|
| Brand_mod_bl4ckbird -> "b4b" |
|
|
| Brand_mod_bl4ckf0x -> "b4f" |
|
|
| Brand_mod_rt -> "rt" |
|
|
| Brand_mod_airionix -> "aio" |
|
|
| Brand_mod_ionix -> "ion" |
|
|
| Brand_mod_tornado -> "tor" |
|
|
| Brand_mod_antifaker -> "anf" |
|
|
| Brand_mod_netf -> "nef" |
|
|
| Brand_mod_nextemf -> "nxf" |
|
|
| Brand_mod_proemule -> "pem" |
|
|
| Brand_mod_szemule -> "sze" |
|
|
| Brand_mod_darkmule -> "dar" |
|
|
| Brand_mod_miragemod -> "mir" |
|
|
| Brand_mod_nextevolution -> "nxe" |
|
|
| Brand_mod_pootzgrila -> "poo" |
|
|
| Brand_mod_freeangel -> "fre" |
|
|
| Brand_mod_enos -> "eno" |
|
|
| Brand_mod_webys -> "wys" |
|
|
|
|
|
let stats_all = dummy_stats |
|
|
let mod_stats_all = dummy_mod_stats |
|
|
let stats_by_brand = Array.init brand_count (fun _ -> |
|
|
{ dummy_stats with brand_seen = 0 } |
|
39 |
) |
) |
40 |
|
let stats_mod_array = Array.init brand_mod_count (fun _ -> |
41 |
let stats_by_brand_mod = Array.init brand_mod_count (fun _ -> |
{ dummy_stats with brand_seen = 0 } |
|
{ dummy_mod_stats with brand_mod_seen = 0 } |
|
42 |
) |
) |
43 |
|
|
|
let start_session = ref start_time |
|
|
|
|
44 |
let count_seen c = |
let count_seen c = |
45 |
stats_all.brand_seen <- stats_all.brand_seen + 1; |
let i = brand_to_int c.client_brand in |
46 |
if !!emule_mods_count && c.client_mod_brand <> Brand_mod_unknown then mod_stats_all.brand_mod_seen <- mod_stats_all.brand_mod_seen + 1; |
stats_array.(i).brand_seen <- stats_array.(i).brand_seen + 1; |
47 |
(match c.client_brand with |
!!gstats_array.(i).brand_seen <- !!gstats_array.(i).brand_seen + 1; |
48 |
Brand_unknown -> () (* be careful, raising an exception here will |
|
|
abort all other operations after that point for this client...*) |
|
|
| b -> |
|
|
stats_by_brand.(brand_to_int b).brand_seen <- |
|
|
stats_by_brand.(brand_to_int b).brand_seen + 1; |
|
|
!!gstats_by_brand.(brand_to_int b).brand_seen <- |
|
|
!!gstats_by_brand.(brand_to_int b).brand_seen + 1); |
|
49 |
if !!emule_mods_count then begin |
if !!emule_mods_count then begin |
50 |
(match c.client_mod_brand with |
let i = brand_mod_to_int c.client_brand_mod in |
51 |
Brand_mod_unknown -> () (* be careful, raising an exception here will |
stats_mod_array.(i).brand_seen <- stats_mod_array.(i).brand_seen + 1; |
52 |
abort all other operations after that point for this client...*) |
!!gstats_mod_array.(i).brand_seen <- !!gstats_mod_array.(i).brand_seen + 1 |
|
| b -> |
|
|
stats_by_brand_mod.(brand_mod_to_int b).brand_mod_seen <- |
|
|
stats_by_brand_mod.(brand_mod_to_int b).brand_mod_seen + 1; |
|
|
!!gstats_by_brand_mod.(brand_mod_to_int b).brand_mod_seen <- |
|
|
!!gstats_by_brand_mod.(brand_mod_to_int b).brand_mod_seen + 1) |
|
53 |
end |
end |
54 |
|
|
55 |
let count_banned c = |
let count_banned c = |
56 |
stats_all.brand_banned <- stats_all.brand_banned + 1; |
let i = brand_to_int c.client_brand in |
57 |
if !!emule_mods_count && c.client_mod_brand <> Brand_mod_unknown then mod_stats_all.brand_mod_banned <- mod_stats_all.brand_mod_banned + 1; |
stats_array.(i).brand_banned <- stats_array.(i).brand_banned + 1; |
58 |
(match c.client_brand with |
!!gstats_array.(i).brand_banned <- !!gstats_array.(i).brand_banned + 1; |
59 |
Brand_unknown -> () |
|
|
| b -> |
|
|
stats_by_brand.(brand_to_int b).brand_banned <- |
|
|
stats_by_brand.(brand_to_int b).brand_banned + 1; |
|
|
!!gstats_by_brand.(brand_to_int b).brand_banned <- |
|
|
!!gstats_by_brand.(brand_to_int b).brand_banned + 1); |
|
60 |
if !!emule_mods_count then begin |
if !!emule_mods_count then begin |
61 |
(match c.client_mod_brand with |
let i = brand_mod_to_int c.client_brand_mod in |
62 |
Brand_mod_unknown -> () |
stats_mod_array.(i).brand_banned <- stats_mod_array.(i).brand_banned + 1; |
63 |
| b -> |
!!gstats_mod_array.(i).brand_banned <- !!gstats_mod_array.(i).brand_banned + 1 |
|
stats_by_brand_mod.(brand_mod_to_int b).brand_mod_banned <- |
|
|
stats_by_brand_mod.(brand_mod_to_int b).brand_mod_banned + 1; |
|
|
!!gstats_by_brand_mod.(brand_mod_to_int b).brand_mod_banned <- |
|
|
!!gstats_by_brand_mod.(brand_mod_to_int b).brand_mod_banned + 1) |
|
64 |
end |
end |
65 |
|
|
66 |
let count_filerequest c = |
let count_filerequest c = |
67 |
stats_all.brand_filerequest <- stats_all.brand_filerequest + 1; |
let i = brand_to_int c.client_brand in |
68 |
if !!emule_mods_count && c.client_mod_brand <> Brand_mod_unknown then mod_stats_all.brand_mod_filerequest <- mod_stats_all.brand_mod_filerequest + 1; |
stats_array.(i).brand_filerequest <- stats_array.(i).brand_filerequest + 1; |
69 |
(match c.client_brand with |
!!gstats_array.(i).brand_filerequest <- !!gstats_array.(i).brand_filerequest + 1; |
|
Brand_unknown -> () |
|
|
| b -> |
|
|
stats_by_brand.(brand_to_int b).brand_filerequest <- |
|
|
stats_by_brand.(brand_to_int b).brand_filerequest + 1; |
|
|
!!gstats_by_brand.(brand_to_int b).brand_filerequest <- |
|
|
!!gstats_by_brand.(brand_to_int b).brand_filerequest + 1); |
|
|
if !!emule_mods_count then begin |
|
|
(match c.client_mod_brand with |
|
|
Brand_mod_unknown -> () |
|
|
| b -> |
|
|
stats_by_brand_mod.(brand_mod_to_int b).brand_mod_filerequest <- |
|
|
stats_by_brand_mod.(brand_mod_to_int b).brand_mod_filerequest + 1; |
|
|
!!gstats_by_brand_mod.(brand_mod_to_int b).brand_mod_filerequest <- |
|
|
!!gstats_by_brand_mod.(brand_mod_to_int b).brand_mod_filerequest + 1) |
|
|
end |
|
70 |
|
|
|
let count_download c f v = |
|
|
download_counter := !download_counter ++ v; |
|
|
c.client_downloaded <- c.client_downloaded ++ v; |
|
|
stats_all.brand_download <- stats_all.brand_download ++ v; |
|
|
donkey_download_counter := !donkey_download_counter ++ v; |
|
|
if !!emule_mods_count && c.client_mod_brand <> Brand_mod_unknown then |
|
|
mod_stats_all.brand_mod_download <- mod_stats_all.brand_mod_download ++ v; |
|
|
(match c.client_brand with |
|
|
Brand_unknown -> () |
|
|
| b -> |
|
|
stats_by_brand.(brand_to_int b).brand_download <- |
|
|
stats_by_brand.(brand_to_int b).brand_download ++ v; |
|
|
!!gstats_by_brand.(brand_to_int b).brand_download <- |
|
|
!!gstats_by_brand.(brand_to_int b).brand_download ++ v); |
|
71 |
if !!emule_mods_count then begin |
if !!emule_mods_count then begin |
72 |
(match c.client_mod_brand with |
let i = brand_mod_to_int c.client_brand_mod in |
73 |
Brand_mod_unknown -> () |
stats_mod_array.(i).brand_filerequest <- stats_mod_array.(i).brand_filerequest + 1; |
74 |
| b -> |
!!gstats_mod_array.(i).brand_filerequest <- !!gstats_mod_array.(i).brand_filerequest + 1 |
|
stats_by_brand_mod.(brand_mod_to_int b).brand_mod_download <- |
|
|
stats_by_brand_mod.(brand_mod_to_int b).brand_mod_download ++ v; |
|
|
!!gstats_by_brand_mod.(brand_mod_to_int b).brand_mod_download <- |
|
|
!!gstats_by_brand_mod.(brand_mod_to_int b).brand_mod_download ++ v) |
|
75 |
end |
end |
76 |
|
|
77 |
let count_upload c f v = |
let count_download c v = |
78 |
upload_counter := !upload_counter ++ v; |
let i = brand_to_int c.client_brand in |
79 |
c.client_uploaded <- c.client_uploaded ++ v; |
stats_array.(i).brand_download <- stats_array.(i).brand_download ++ v; |
80 |
stats_all.brand_upload <- stats_all.brand_upload ++ v; |
!!gstats_array.(i).brand_download <- !!gstats_array.(i).brand_download ++ v; |
|
donkey_upload_counter := !donkey_upload_counter ++ v; |
|
|
if !!emule_mods_count && c.client_mod_brand <> Brand_mod_unknown then |
|
|
mod_stats_all.brand_mod_upload <- mod_stats_all.brand_mod_upload ++ v; |
|
|
(match c.client_brand with |
|
|
Brand_unknown -> () |
|
|
| b -> |
|
|
stats_by_brand.(brand_to_int b).brand_upload <- |
|
|
stats_by_brand.(brand_to_int b).brand_upload ++ v; |
|
|
!!gstats_by_brand.(brand_to_int b).brand_upload <- |
|
|
!!gstats_by_brand.(brand_to_int b).brand_upload ++ v); |
|
|
if !!emule_mods_count then begin |
|
|
(match c.client_mod_brand with |
|
|
Brand_mod_unknown -> () |
|
|
| b -> |
|
|
stats_by_brand_mod.(brand_mod_to_int b).brand_mod_upload <- |
|
|
stats_by_brand_mod.(brand_mod_to_int b).brand_mod_upload ++ v; |
|
|
!!gstats_by_brand_mod.(brand_mod_to_int b).brand_mod_upload <- |
|
|
!!gstats_by_brand_mod.(brand_mod_to_int b).brand_mod_upload ++ v) |
|
|
end |
|
81 |
|
|
82 |
let percent_of_ints x y = |
if !!emule_mods_count then begin |
83 |
if y <> 0 then 100. *. (float_of_int x /. float_of_int y) |
let i = brand_mod_to_int c.client_brand_mod in |
84 |
else 0. |
stats_mod_array.(i).brand_download <- stats_mod_array.(i).brand_download ++ v; |
85 |
|
!!gstats_mod_array.(i).brand_download <- !!gstats_mod_array.(i).brand_download ++ v; |
|
let percent_of_int64s x y = |
|
|
if y <> Int64.zero then 100. *. (Int64.to_float x /. Int64.to_float y) |
|
|
else 0. |
|
|
|
|
|
let print_stats buf = |
|
|
let one_minute = 60 in |
|
|
let one_hour = 3600 in |
|
|
let one_day = 86400 in |
|
|
let session_time = last_time () - !start_session in |
|
|
let days = session_time / one_day in |
|
|
let rem = session_time - days * one_day in |
|
|
let hours = rem / one_hour in |
|
|
let rem = rem - hours * one_hour in |
|
|
let mins = rem / one_minute in |
|
|
Printf.bprintf buf "Uptime: %d days, %02dh:%02dm (= %d seconds)\n" |
|
|
days hours mins session_time; |
|
|
|
|
|
|
|
|
if stats_all.brand_seen = 0 then |
|
|
Printf.bprintf buf "You haven't connected to any client yet\n" |
|
|
else begin |
|
|
Printf.bprintf buf "\n Successful Connections: %18d\n" stats_all.brand_seen; |
|
|
for i=1 to brand_count-1 do |
|
|
Printf.bprintf buf "%27s: %18d (%5.1f %%)\n" |
|
|
(brand_to_string (brand_of_int i)) |
|
|
stats_by_brand.(i).brand_seen |
|
|
(percent_of_ints stats_by_brand.(i).brand_seen stats_all.brand_seen) |
|
|
done |
|
86 |
end; |
end; |
87 |
|
|
88 |
if stats_all.brand_filerequest = 0 then |
c.client_downloaded <- c.client_downloaded ++ v; |
89 |
Printf.bprintf buf "You weren't asked for any file yet\n" |
donkey_download_counter := !donkey_download_counter ++ v; |
90 |
else begin |
global_count_download network v |
|
Printf.bprintf buf "\nTotal filerequests received: %18d\n" stats_all.brand_filerequest; |
|
|
for i=1 to brand_count-1 do |
|
|
Printf.bprintf buf "%27s: %18d (%5.1f %%)\n" |
|
|
(brand_to_string (brand_of_int i)) |
|
|
stats_by_brand.(i).brand_filerequest |
|
|
(percent_of_ints stats_by_brand.(i).brand_filerequest stats_all.brand_filerequest) |
|
|
done |
|
|
end; |
|
91 |
|
|
92 |
if stats_all.brand_download = Int64.zero then |
let count_upload c v = |
93 |
Printf.bprintf buf "You didn't download anything yet\n" |
let i = brand_to_int c.client_brand in |
94 |
else begin |
stats_array.(i).brand_upload <- stats_array.(i).brand_upload ++ v; |
95 |
Printf.bprintf buf "\n Total downloads: %18s (%5.1f KB/s)\n" |
!!gstats_array.(i).brand_upload <- !!gstats_array.(i).brand_upload ++ v; |
|
(Int64.to_string stats_all.brand_download) |
|
|
((Int64.to_float stats_all.brand_download) /. (float_of_int session_time) /. 1024.0); |
|
|
for i=1 to brand_count-1 do |
|
|
Printf.bprintf buf "%27s: %18s (%5.1f %%)\n" |
|
|
(brand_to_string (brand_of_int i)) |
|
|
(Int64.to_string stats_by_brand.(i).brand_download) |
|
|
(percent_of_int64s stats_by_brand.(i).brand_download stats_all.brand_download) |
|
|
done |
|
|
end; |
|
96 |
|
|
97 |
if stats_all.brand_upload = Int64.zero then |
if !!emule_mods_count then begin |
98 |
Printf.bprintf buf "You didn't upload anything yet\n" |
let i = brand_mod_to_int c.client_brand_mod in |
99 |
else begin |
stats_mod_array.(i).brand_upload <- stats_mod_array.(i).brand_upload ++ v; |
100 |
Printf.bprintf buf "\n Total uploads: %18s (%5.1f KB/s)\n" |
!!gstats_mod_array.(i).brand_upload <- !!gstats_mod_array.(i).brand_upload ++ v; |
|
(Int64.to_string stats_all.brand_upload) |
|
|
((Int64.to_float stats_all.brand_upload) /. (float_of_int session_time) /. 1024.0); |
|
|
for i=1 to brand_count-1 do |
|
|
Printf.bprintf buf "%27s: %18s (%5.1f %%)\n" |
|
|
(brand_to_string (brand_of_int i)) |
|
|
(Int64.to_string stats_by_brand.(i).brand_upload) |
|
|
(percent_of_int64s stats_by_brand.(i).brand_upload stats_all.brand_upload) |
|
|
done |
|
101 |
end; |
end; |
102 |
|
|
103 |
if stats_all.brand_banned = 0 then |
c.client_uploaded <- c.client_uploaded ++ v; |
104 |
Printf.bprintf buf "You didn't ban any client yet\n" |
donkey_upload_counter := !donkey_upload_counter ++ v; |
105 |
else begin |
global_count_upload network v |
|
Printf.bprintf buf "\n Total bans: %18d\n" stats_all.brand_banned; |
|
|
for i=1 to brand_count-1 do |
|
|
Printf.bprintf buf "%27s: %18d (%5.1f %%)\n" |
|
|
(brand_to_string (brand_of_int i)) |
|
|
stats_by_brand.(i).brand_banned |
|
|
(percent_of_ints stats_by_brand.(i).brand_banned stats_all.brand_banned) |
|
|
done |
|
|
end |
|
|
|
|
|
|
|
|
let stats_html_header buf = |
|
|
html_mods_table_header buf "csTable" "cs" [ |
|
|
( "0", "srh", "Client brand", "Brand" ) ; |
|
|
( "0", "srh", "Separator", ":" ) ; |
|
|
( "1", "srh ar", "Successful connections", "Seen" ) ; |
|
|
( "1", "srh", "Successful connections percent", "%" ) ; |
|
|
( "0", "srh", "Separator", "|" ) ; |
|
|
( "1", "srh ar", "File requests received", "Reqs" ) ; |
|
|
( "1", "srh", "File requests received percent", "%" ) ; |
|
|
( "0", "srh", "Separator", "|" ) ; |
|
|
( "1", "srh ar", "Total bans", "B" ) ; |
|
|
( "1", "srh", "Total bans percent", "%" ) ; |
|
|
( "0", "srh", "Separator", "|" ) ; |
|
|
( "1", "srh ar", "Total uploads", "UL" ) ; |
|
|
( "1", "srh", "Total uploads percent", "%" ) ; |
|
|
( "1", "srh ar", "Total uploads average KB/s", "KB/s" ) ; |
|
|
( "0", "srh", "Separator", "|" ) ; |
|
|
( "1", "srh ar", "Total downloads", "DL" ) ; |
|
|
( "1", "srh", "Total downloads percent", "%" ) ; |
|
|
( "1", "srh ar", "Total downloads average KB/s", "KB/s" ) ; |
|
|
( "0", "srh", "Separator", "|" ) ; |
|
|
( "1", "srh", "Total uploads:downloads ratio", "U:DL" ) ] |
|
|
|
|
|
let new_print_stats buf o = |
|
|
let one_minute = 60 in |
|
|
let one_hour = 3600 in |
|
|
let one_day = 86400 in |
|
|
let session_time = last_time () - !start_session in |
|
|
let uptime = last_time () - start_time in |
|
|
let days = session_time / one_day in |
|
|
let rem = maxi 1 (session_time - days * one_day) in |
|
|
|
|
|
let hours = rem / one_hour in |
|
|
let rem = rem - hours * one_hour in |
|
|
let mins = rem / one_minute in |
|
|
|
|
|
let sstats_all = |
|
|
let stat = { |
|
|
brand_seen = 0; |
|
|
brand_banned = 0; |
|
|
brand_filerequest = 0; |
|
|
brand_download = Int64.zero; |
|
|
brand_upload = Int64.zero |
|
|
} |
|
|
in stat in |
|
|
|
|
|
for i=0 to brand_count-1 do |
|
|
if ( brand_of_int i != Brand_server ) then begin |
|
|
sstats_all.brand_seen <- sstats_all.brand_seen + stats_by_brand.(i).brand_seen; |
|
|
sstats_all.brand_filerequest <- sstats_all.brand_filerequest + stats_by_brand.(i).brand_filerequest; |
|
|
sstats_all.brand_download <- sstats_all.brand_download ++ stats_by_brand.(i).brand_download ; |
|
|
sstats_all.brand_upload <- sstats_all.brand_upload ++ stats_by_brand.(i).brand_upload; |
|
|
sstats_all.brand_banned <- sstats_all.brand_banned + stats_by_brand.(i).brand_banned; |
|
|
end; |
|
|
done; |
|
|
|
|
|
let gstats_all = |
|
|
let stat = { |
|
|
brand_seen = 0; |
|
|
brand_banned = 0; |
|
|
brand_filerequest = 0; |
|
|
brand_download = Int64.zero; |
|
|
brand_upload = Int64.zero |
|
|
} |
|
|
in stat in |
|
|
|
|
|
for i=0 to brand_count-1 do |
|
|
gstats_all.brand_seen <- gstats_all.brand_seen + !!gstats_by_brand.(i).brand_seen; |
|
|
gstats_all.brand_filerequest <- gstats_all.brand_filerequest + !!gstats_by_brand.(i).brand_filerequest; |
|
|
gstats_all.brand_download <- gstats_all.brand_download ++ !!gstats_by_brand.(i).brand_download ; |
|
|
gstats_all.brand_upload <- gstats_all.brand_upload ++ !!gstats_by_brand.(i).brand_upload; |
|
|
gstats_all.brand_banned <- gstats_all.brand_banned + !!gstats_by_brand.(i).brand_banned; |
|
|
done; |
|
|
|
|
|
if use_html_mods o then |
|
|
begin |
|
|
Buffer.add_string buf "\\<div class=\\\"cs\\\"\\>\n"; |
|
|
html_mods_table_one_row buf "csTable" "cs" [ |
|
|
("", "srh", |
|
|
Printf.sprintf "eDonkey - Session Uptime: %d days, %02dh:%02dm (= %d seconds)" |
|
|
days hours mins session_time); ]; |
|
|
Buffer.add_string buf "\\</div\\>\n"; |
|
|
|
|
|
stats_html_header buf; |
|
|
|
|
|
let counter = ref 0 in |
|
|
let showTotal = ref false in |
|
|
|
|
|
for i=1 to brand_count do |
|
|
if i=brand_count then showTotal := true; |
|
|
if !showTotal || ( brand_of_int i != Brand_server && stats_by_brand.(i).brand_seen > 0 ) then begin |
|
|
incr counter; |
|
|
Printf.bprintf buf "\\<tr class=\\\"%s\\\"\\>" (if (!counter mod 2 == 0) then "dl-1" else "dl-2"); |
|
|
Printf.bprintf buf " |
|
|
\\<td class=\\\"sr\\\"\\>%s\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>:\\</td\\> |
|
|
\\<td class=\\\"sr ar\\\"\\>%d\\</td\\> |
|
|
\\<td class=\\\"srp \\\"\\>(%.f%%)\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr ar\\\"\\>%d\\</td\\> |
|
|
\\<td class=\\\"srp \\\"\\>(%.f%%)\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr ar\\\"\\>%d\\</td\\> |
|
|
\\<td class=\\\"srp\\\"\\>(%.0f%%)\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr ar\\\"\\>%s\\</td\\> |
|
|
\\<td class=\\\"srp \\\"\\>(%.0f%%)\\</td\\> |
|
|
\\<td class=\\\"sr ar\\\"\\>%.1f\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr ar\\\"\\>%s\\</td\\> |
|
|
\\<td class=\\\"srp \\\"\\>(%.0f%%)\\</td\\> |
|
|
\\<td class=\\\"sr ar \\\"\\>%.1f\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr \\\"\\>1:%.2f\\</td\\> |
|
|
\\</tr\\>\n" |
|
|
|
|
|
(if !showTotal then "Total" else (brand_to_string (brand_of_int i))) |
|
|
|
|
|
(if !showTotal then sstats_all.brand_seen else |
|
|
stats_by_brand.(i).brand_seen) |
|
|
|
|
|
(if !showTotal then 100.0 else (percent_of_ints |
|
|
stats_by_brand.(i).brand_seen stats_all.brand_seen)) |
|
|
|
|
|
(if !showTotal then sstats_all.brand_filerequest else stats_by_brand.(i).brand_filerequest) |
|
|
|
|
|
(if !showTotal then 100.0 else (percent_of_ints stats_by_brand.(i).brand_filerequest stats_all.brand_filerequest)) |
|
|
|
|
|
(if !showTotal then sstats_all.brand_banned else |
|
|
stats_by_brand.(i).brand_banned) |
|
|
|
|
|
(max 0.0 (if !showTotal then (percent_of_ints sstats_all.brand_banned sstats_all.brand_seen) |
|
|
else (percent_of_ints stats_by_brand.(i).brand_banned stats_all.brand_banned))) |
|
|
|
|
|
(size_of_int64 (if !showTotal then sstats_all.brand_upload else |
|
|
stats_by_brand.(i).brand_upload)) |
|
|
|
|
|
(max 0.0 (if !showTotal then 100.0 else (percent_of_int64s |
|
|
stats_by_brand.(i).brand_upload stats_all.brand_upload))) |
|
|
|
|
|
(if !showTotal then ((Int64.to_float sstats_all.brand_upload) /. (float_of_int session_time) /. 1024.0) |
|
|
else ((Int64.to_float stats_by_brand.(i).brand_upload) /. (float_of_int session_time) /. 1024.0)) |
|
|
|
|
|
(size_of_int64 (if !showTotal then sstats_all.brand_download else |
|
|
stats_by_brand.(i).brand_download)) |
|
|
|
|
|
(max 0.0 (if !showTotal then 100.0 else (percent_of_int64s |
|
|
stats_by_brand.(i).brand_download stats_all.brand_download))) |
|
|
|
|
|
(if !showTotal then ((Int64.to_float sstats_all.brand_download) /. (float_of_int session_time) /. 1024.0) |
|
|
else ((Int64.to_float stats_by_brand.(i).brand_download) /. (float_of_int session_time) /. 1024.0)) |
|
|
|
|
|
(if !showTotal then |
|
|
(if sstats_all.brand_upload = Int64.zero then 0.0 else |
|
|
( (Int64.to_float sstats_all.brand_download) /. (Int64.to_float sstats_all.brand_upload) )) |
|
|
else |
|
|
(if stats_by_brand.(i).brand_upload = Int64.zero then 0.0 else |
|
|
( (Int64.to_float stats_by_brand.(i).brand_download) /. |
|
|
(Int64.to_float stats_by_brand.(i).brand_upload) ))); |
|
|
end |
|
|
done; |
|
|
Buffer.add_string buf "\\</table\\>\\</div\\>\n"; |
|
|
|
|
|
let gdays = (guptime () + uptime) / one_day in |
|
|
let grem = maxi 1 ((guptime () + uptime) - gdays * one_day) in |
|
|
|
|
|
let ghours = grem / one_hour in |
|
|
let grem = grem - ghours * one_hour in |
|
|
let gmins = grem / one_minute in |
|
|
|
|
|
Buffer.add_string buf "\\<div class=\\\"cs\\\"\\>\n"; |
|
|
html_mods_table_one_row buf "csTable" "cs" [ |
|
|
("", "srh", |
|
|
Printf.sprintf "eDonkey - Total Uptime: %d days, %02dh:%02dm (= %d seconds)" |
|
|
gdays ghours gmins (guptime() + uptime)); ]; |
|
|
Buffer.add_string buf "\\</div\\>\n"; |
|
|
|
|
|
stats_html_header buf; |
|
|
|
|
|
showTotal := false; |
|
|
for i=1 to brand_count do |
|
|
if i=brand_count then showTotal := true; |
|
|
if !showTotal || ( brand_of_int i != Brand_server && !!gstats_by_brand.(i).brand_seen > 0 ) then begin |
|
|
incr counter; |
|
|
Printf.bprintf buf "\\<tr class=\\\"%s\\\"\\>" (if (!counter mod 2 == 0) then "dl-1" else "dl-2"); |
|
|
Printf.bprintf buf " |
|
|
\\<td class=\\\"sr\\\"\\>%s\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>:\\</td\\> |
|
|
\\<td class=\\\"sr ar\\\"\\>%d\\</td\\> |
|
|
\\<td class=\\\"srp \\\"\\>(%.f%%)\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr ar\\\"\\>%d\\</td\\> |
|
|
\\<td class=\\\"srp \\\"\\>(%.f%%)\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr ar\\\"\\>%d\\</td\\> |
|
|
\\<td class=\\\"srp\\\"\\>(%.0f%%)\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr ar\\\"\\>%s\\</td\\> |
|
|
\\<td class=\\\"srp \\\"\\>(%.0f%%)\\</td\\> |
|
|
\\<td class=\\\"sr ar\\\"\\>%.1f\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr ar\\\"\\>%s\\</td\\> |
|
|
\\<td class=\\\"srp \\\"\\>(%.0f%%)\\</td\\> |
|
|
\\<td class=\\\"sr ar \\\"\\>%.1f\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr \\\"\\>1:%.2f\\</td\\> |
|
|
|
|
|
\\</tr\\>\n" |
|
|
|
|
|
(if !showTotal then "Total" else (brand_to_string (brand_of_int i)) ) |
|
|
|
|
|
(if !showTotal then gstats_all.brand_seen else !!gstats_by_brand.(i).brand_seen) |
|
|
|
|
|
(if !showTotal then 100. else (percent_of_ints (!!gstats_by_brand.(i).brand_seen) gstats_all.brand_seen)) |
|
|
|
|
|
(if !showTotal then gstats_all.brand_filerequest else !!gstats_by_brand.(i).brand_filerequest) |
|
|
|
|
|
(if !showTotal then 100. else (percent_of_ints (!!gstats_by_brand.(i).brand_filerequest) gstats_all.brand_filerequest)) |
|
|
|
|
|
(if !showTotal then gstats_all.brand_banned else !!gstats_by_brand.(i).brand_banned) |
|
|
|
|
|
(max 0.0 (if !showTotal then (percent_of_ints gstats_all.brand_banned |
|
|
gstats_all.brand_seen) else (percent_of_ints (!!gstats_by_brand.(i).brand_banned) gstats_all.brand_banned))) |
|
|
|
|
|
(size_of_int64 (if !showTotal then gstats_all.brand_upload else !!gstats_by_brand.(i).brand_upload)) |
|
|
|
|
|
(if !showTotal then 100. else (max 0.0 (percent_of_int64s |
|
|
(!!gstats_by_brand.(i).brand_upload) gstats_all.brand_upload))) |
|
|
|
|
|
(if !showTotal then ((Int64.to_float gstats_all.brand_upload) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
|
|
else ((Int64.to_float (!!gstats_by_brand.(i).brand_upload)) /. (float_of_int (guptime() + uptime)) /. 1024.0)) |
|
|
|
|
|
(size_of_int64 (if !showTotal then gstats_all.brand_download else !!gstats_by_brand.(i).brand_download)) |
|
106 |
|
|
107 |
(if !showTotal then 100. else (max 0.0 (percent_of_int64s |
let print_stats_mods o style = |
108 |
(!!gstats_by_brand.(i).brand_download) gstats_all.brand_download))) |
let buf = o.conn_buf in |
109 |
|
|
110 |
(if !showTotal then ((Int64.to_float gstats_all.brand_download) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
let u1 = BasicSocket.last_time () - !start_session in |
111 |
else ((Int64.to_float (!!gstats_by_brand.(i).brand_download)) /. (float_of_int (guptime() + uptime)) /. 1024.0)) |
let u2 = (guptime() + u1) in |
112 |
|
|
113 |
(if !showTotal then (if gstats_all.brand_upload = Int64.zero then 0.0 else |
let t1 = build_title "eMule Mods" "Session" u1 in |
114 |
((Int64.to_float gstats_all.brand_download) /. (Int64.to_float gstats_all.brand_upload) )) else |
let t2 = build_title "eMule Mods" "Total" u2 in |
115 |
(if !!gstats_by_brand.(i).brand_upload = Int64.zero then 0.0 else |
|
116 |
( (Int64.to_float !!gstats_by_brand.(i).brand_download) /. |
let l = brand_mod_list in |
117 |
(Int64.to_float !!gstats_by_brand.(i).brand_upload) ))) |
|
118 |
|
match style with |
119 |
|
| Old -> print_stats_old buf stats_mod_array l t1 u1 |
120 |
|
| _ -> |
121 |
|
if !!emule_mods_count then begin |
122 |
|
|
123 |
|
if use_html_mods o then begin |
124 |
|
print_stats_html_mods buf stats_mod_array l t1 u1; |
125 |
|
print_stats_html_mods buf !!gstats_mod_array l t2 u2 |
126 |
|
end else begin |
127 |
|
print_stats_ascii buf stats_mod_array l t1 u1; |
128 |
|
print_stats_ascii buf !!gstats_mod_array l t2 u2 |
129 |
end |
end |
130 |
done; |
|
131 |
Buffer.add_string buf "\\</table\\>\\</div\\>\n"; |
end else |
132 |
end |
begin |
|
else |
|
|
begin |
|
|
Printf.bprintf buf "eDonkey - Session Uptime: %d days, %02dh:%02dm (= %d seconds)\n" |
|
|
days hours mins session_time; |
|
|
Printf.bprintf buf "Client Brand| seen | Downloads | Uploads | Banned | Requests\n"; |
|
|
Printf.bprintf buf "------------+--------------+--------------------+--------------------+------------+--------------\n"; |
|
|
|
|
|
for i=1 to brand_count-1 do |
|
|
if brand_of_int i != Brand_server && stats_by_brand.(i).brand_seen > 0 then (* dont print server stats *) |
|
|
let brandstr = |
|
|
if brand_of_int i = Brand_mldonkey3 then |
|
|
"trusted mld" |
|
|
else |
|
|
brand_to_string (brand_of_int i) in |
|
|
|
|
|
Printf.bprintf buf "%-12s|%9d %3.f%%|%9.1f %5.1f %3.0f%%|%9.1f %5.1f %3.0f%%|%7d %3.0f%%|%9d %3.0f%%\n" |
|
|
(brandstr) |
|
|
stats_by_brand.(i).brand_seen |
|
|
(percent_of_ints stats_by_brand.(i).brand_seen stats_all.brand_seen) |
|
|
((Int64.to_float stats_by_brand.(i).brand_download) /. 1024.0 /. 1024.0) |
|
|
((Int64.to_float stats_by_brand.(i).brand_download) /. (float_of_int session_time) /. 1024.0) |
|
|
(percent_of_int64s stats_by_brand.(i).brand_download stats_all.brand_download) |
|
|
((Int64.to_float stats_by_brand.(i).brand_upload) /. 1024.0 /. 1024.0) |
|
|
((Int64.to_float stats_by_brand.(i).brand_upload) /. (float_of_int session_time) /. 1024.0) |
|
|
(percent_of_int64s stats_by_brand.(i).brand_upload stats_all.brand_upload) |
|
|
stats_by_brand.(i).brand_banned |
|
|
(percent_of_ints stats_by_brand.(i).brand_banned stats_all.brand_banned) |
|
|
stats_by_brand.(i).brand_filerequest |
|
|
(percent_of_ints stats_by_brand.(i).brand_filerequest stats_all.brand_filerequest) |
|
|
done; |
|
|
|
|
|
Printf.bprintf buf "------------+--------------+--------------------+--------------------+------------+--------------\n"; |
|
|
Printf.bprintf buf "%-12s|%9d |%9.1f %5.1f |%9.1f %5.1f |%7d |%9d\n" |
|
|
"Total" |
|
|
sstats_all.brand_seen |
|
|
((Int64.to_float sstats_all.brand_download) /. 1024.0 /. 1024.0) |
|
|
((Int64.to_float sstats_all.brand_download) /. (float_of_int session_time) /. 1024.0) |
|
|
((Int64.to_float sstats_all.brand_upload) /. 1024.0 /. 1024.0) |
|
|
((Int64.to_float sstats_all.brand_upload) /. (float_of_int session_time) /. 1024.0) |
|
|
sstats_all.brand_banned |
|
|
sstats_all.brand_filerequest; |
|
|
|
|
|
let gdays = (guptime () + uptime) / one_day in |
|
|
let grem = maxi 1 ((guptime () + uptime) - gdays * one_day) in |
|
|
let ghours = grem / one_hour in |
|
|
let grem = grem - ghours * one_hour in |
|
|
let gmins = grem / one_minute in |
|
|
Printf.bprintf buf "\neDonkey - Total Uptime: %d days, %02dh:%02dm (= %d seconds)\n" |
|
|
gdays ghours gmins (guptime() + uptime); |
|
|
Printf.bprintf buf "Client Brand| seen | Downloads | Uploads | Banned | Requests\n"; |
|
|
Printf.bprintf buf "------------+--------------+--------------------+--------------------+------------+--------------\n"; |
|
|
|
|
|
for i=1 to brand_count-1 do |
|
|
if brand_of_int i != Brand_server && !!gstats_by_brand.(i).brand_seen > 0 then (* dont print server stats *) |
|
|
let brandstr = |
|
|
if brand_of_int i = Brand_mldonkey3 then |
|
|
"trusted mld" |
|
|
else |
|
|
brand_to_string (brand_of_int i) in |
|
|
|
|
|
Printf.bprintf buf "%-12s|%9d %3.f%%|%9.1f %5.1f %3.0f%%|%9.1f %5.1f %3.0f%%|%7d %3.0f%%|%9d %3.0f%%\n" |
|
|
(brandstr) |
|
|
!!gstats_by_brand.(i).brand_seen |
|
|
(percent_of_ints !!gstats_by_brand.(i).brand_seen gstats_all.brand_seen) |
|
|
((Int64.to_float !!gstats_by_brand.(i).brand_download) /. 1024.0 /. 1024.0) |
|
|
((Int64.to_float !!gstats_by_brand.(i).brand_download) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
|
|
(percent_of_int64s !!gstats_by_brand.(i).brand_download gstats_all.brand_download) |
|
|
((Int64.to_float !!gstats_by_brand.(i).brand_upload) /. 1024.0 /. 1024.0) |
|
|
((Int64.to_float !!gstats_by_brand.(i).brand_upload) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
|
|
(percent_of_int64s !!gstats_by_brand.(i).brand_upload gstats_all.brand_upload) |
|
|
!!gstats_by_brand.(i).brand_banned |
|
|
(percent_of_ints !!gstats_by_brand.(i).brand_banned gstats_all.brand_banned) |
|
|
!!gstats_by_brand.(i).brand_filerequest |
|
|
(percent_of_ints !!gstats_by_brand.(i).brand_filerequest gstats_all.brand_filerequest) |
|
|
done; |
|
|
|
|
|
Printf.bprintf buf "------------+--------------+--------------------+--------------------+------------+--------------\n"; |
|
|
Printf.bprintf buf "%-12s|%9d |%9.1f %5.1f |%9.1f %5.1f |%7d |%9d\n" |
|
|
"Total" |
|
|
gstats_all.brand_seen |
|
|
((Int64.to_float gstats_all.brand_download) /. 1024.0 /. 1024.0) |
|
|
((Int64.to_float gstats_all.brand_download) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
|
|
((Int64.to_float gstats_all.brand_upload) /. 1024.0 /. 1024.0) |
|
|
((Int64.to_float gstats_all.brand_upload) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
|
|
gstats_all.brand_banned |
|
|
gstats_all.brand_filerequest; |
|
|
|
|
|
end |
|
|
|
|
|
let new_print_mod_stats buf o = |
|
|
let one_minute = 60 in |
|
|
let one_hour = 3600 in |
|
|
let one_day = 86400 in |
|
|
let session_time = last_time () - !start_session in |
|
|
let uptime = last_time () - start_time in |
|
|
let days = session_time / one_day in |
|
|
let rem = maxi 1 (session_time - days * one_day) in |
|
|
|
|
|
let hours = rem / one_hour in |
|
|
let rem = rem - hours * one_hour in |
|
|
let mins = rem / one_minute in |
|
|
|
|
|
if !!emule_mods_count then |
|
|
|
|
|
if use_html_mods o then |
|
|
begin |
|
|
Buffer.add_string buf "\\<div class=\\\"cs\\\"\\>\n"; |
|
|
html_mods_table_one_row buf "csTable" "cs" [ |
|
|
("", "srh", |
|
|
Printf.sprintf "eMule Mods - Session Uptime: %d days, %02dh:%02dm (= %d seconds)" |
|
|
days hours mins session_time); ]; |
|
|
Buffer.add_string buf "\\</div\\>\n"; |
|
|
stats_html_header buf; |
|
|
|
|
|
let counter = ref 0 in |
|
|
let showTotal = ref false in |
|
|
|
|
|
for i=1 to brand_mod_count do |
|
|
if i=brand_mod_count then showTotal := true; |
|
|
if !showTotal || ( !!emule_mods_showall || stats_by_brand_mod.(i).brand_mod_seen > 0 ) then begin |
|
|
incr counter; |
|
|
Printf.bprintf buf "\\<tr class=\\\"%s\\\"\\>" (if (!counter mod 2 == 0) then "dl-1" else "dl-2"); |
|
|
Printf.bprintf buf " |
|
|
\\<td class=\\\"sr\\\"\\>%s\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>:\\</td\\> |
|
|
\\<td class=\\\"sr ar\\\"\\>%d\\</td\\> |
|
|
\\<td class=\\\"srp \\\"\\>(%.f%%)\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr ar\\\"\\>%d\\</td\\> |
|
|
\\<td class=\\\"srp \\\"\\>(%.f%%)\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr ar\\\"\\>%d\\</td\\> |
|
|
\\<td class=\\\"srp\\\"\\>(%.0f%%)\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr ar\\\"\\>%s\\</td\\> |
|
|
\\<td class=\\\"srp \\\"\\>(%.0f%%)\\</td\\> |
|
|
\\<td class=\\\"sr ar\\\"\\>%.1f\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr ar\\\"\\>%s\\</td\\> |
|
|
\\<td class=\\\"srp \\\"\\>(%.0f%%)\\</td\\> |
|
|
\\<td class=\\\"sr ar \\\"\\>%.1f\\</td\\> |
|
|
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
|
|
|
|
\\<td class=\\\"sr \\\"\\>1:%.2f\\</td\\> |
|
|
\\</tr\\>\n" |
|
|
|
|
|
(if !showTotal then "Total" else (brand_mod_to_string (brand_mod_of_int i))) |
|
|
|
|
|
(if !showTotal then mod_stats_all.brand_mod_seen else |
|
|
stats_by_brand_mod.(i).brand_mod_seen) |
|
|
|
|
|
(if !showTotal then 100.0 else (percent_of_ints |
|
|
stats_by_brand_mod.(i).brand_mod_seen mod_stats_all.brand_mod_seen)) |
|
|
|
|
|
(if !showTotal then mod_stats_all.brand_mod_filerequest else stats_by_brand_mod.(i).brand_mod_filerequest) |
|
|
|
|
|
(if !showTotal then 100.0 else (percent_of_ints stats_by_brand_mod.(i).brand_mod_filerequest mod_stats_all.brand_mod_filerequest)) |
|
|
|
|
|
(if !showTotal then mod_stats_all.brand_mod_banned else |
|
|
stats_by_brand_mod.(i).brand_mod_banned) |
|
|
|
|
|
(max 0.0 (if !showTotal then (percent_of_ints mod_stats_all.brand_mod_banned mod_stats_all.brand_mod_seen) |
|
|
else (percent_of_ints stats_by_brand_mod.(i).brand_mod_banned mod_stats_all.brand_mod_banned))) |
|
|
|
|
|
(size_of_int64 (if !showTotal then mod_stats_all.brand_mod_upload else |
|
|
stats_by_brand_mod.(i).brand_mod_upload)) |
|
|
|
|
|
(max 0.0 (if !showTotal then 100.0 else (percent_of_int64s |
|
|
stats_by_brand_mod.(i).brand_mod_upload mod_stats_all.brand_mod_upload))) |
|
|
|
|
|
(if !showTotal then ((Int64.to_float mod_stats_all.brand_mod_upload) /. (float_of_int session_time) /. 1024.0) |
|
|
else ((Int64.to_float stats_by_brand_mod.(i).brand_mod_upload) /. (float_of_int session_time) /. 1024.0)) |
|
|
|
|
|
(size_of_int64 (if !showTotal then mod_stats_all.brand_mod_download else |
|
|
stats_by_brand_mod.(i).brand_mod_download)) |
|
|
|
|
|
(max 0.0 (if !showTotal then 100.0 else (percent_of_int64s |
|
|
stats_by_brand_mod.(i).brand_mod_download mod_stats_all.brand_mod_download))) |
|
|
|
|
|
(if !showTotal then ((Int64.to_float mod_stats_all.brand_mod_download) /. (float_of_int session_time) /. 1024.0) |
|
|
else ((Int64.to_float stats_by_brand_mod.(i).brand_mod_download) /. (float_of_int session_time) /. 1024.0)) |
|
|
|
|
|
(if !showTotal then |
|
|
(if mod_stats_all.brand_mod_upload = Int64.zero then 0.0 else |
|
|
( (Int64.to_float mod_stats_all.brand_mod_download) /. (Int64.to_float mod_stats_all.brand_mod_upload) )) |
|
|
else |
|
|
(if stats_by_brand_mod.(i).brand_mod_upload = Int64.zero then 0.0 else |
|
|
( (Int64.to_float stats_by_brand_mod.(i).brand_mod_download) /. |
|
|
(Int64.to_float stats_by_brand_mod.(i).brand_mod_upload) ))); |
|
|
end |
|
|
done; |
|
|
Buffer.add_string buf "\\</table\\>\\</div\\>\n"; |
|
|
|
|
|
let gstats_all = |
|
|
let stat = { |
|
|
brand_mod_seen = 0; |
|
|
brand_mod_banned = 0; |
|
|
brand_mod_filerequest = 0; |
|
|
brand_mod_download = Int64.zero; |
|
|
brand_mod_upload = Int64.zero |
|
|
} |
|
|
in stat in |
|
|
|
|
|
for i=0 to brand_mod_count-1 do |
|
|
|
|
|
gstats_all.brand_mod_seen <- gstats_all.brand_mod_seen + !!gstats_by_brand_mod.(i).brand_mod_seen; |
|
|
gstats_all.brand_mod_filerequest <- gstats_all.brand_mod_filerequest + !!gstats_by_brand_mod.(i).brand_mod_filerequest; |
|
|
gstats_all.brand_mod_download <- gstats_all.brand_mod_download ++ !!gstats_by_brand_mod.(i).brand_mod_download ; |
|
|
gstats_all.brand_mod_upload <- gstats_all.brand_mod_upload ++ !!gstats_by_brand_mod.(i).brand_mod_upload; |
|
|
gstats_all.brand_mod_banned <- gstats_all.brand_mod_banned + !!gstats_by_brand_mod.(i).brand_mod_banned; |
|
|
|
|
|
done; |
|
|
let gdays = (guptime () + uptime) / one_day in |
|
|
let grem = maxi 1 ((guptime () + uptime) - gdays * one_day) in |
|
|
|
|
|
let ghours = grem / one_hour in |
|
|
let grem = grem - ghours * one_hour in |
|
|
let gmins = grem / one_minute in |
|
|
|
|
|
Buffer.add_string buf "\\<div class=\\\"cs\\\"\\>\n"; |
|
|
html_mods_table_one_row buf "csTable" "cs" [ |
|
|
("", "srh", |
|
|
Printf.sprintf "eMule Mods - Total Uptime: %d days, %02dh:%02dm (= %d seconds)" |
|
|
gdays ghours gmins (guptime() + uptime)); ]; |
|
|
Buffer.add_string buf "\\</div\\>\n"; |
|
133 |
|
|
134 |
stats_html_header buf; |
if use_html_mods o then begin |
135 |
|
Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>"; |
136 |
showTotal := false; |
html_mods_table_header buf "emodsTable" "cs" []; |
137 |
for i=1 to brand_mod_count do |
Printf.bprintf buf "\\<tr class=\\\"dl-1\\\"\\>"; |
138 |
if i=brand_mod_count then showTotal := true; |
html_mods_td buf [ |
139 |
if !showTotal || ( !!emule_mods_showall || !!gstats_by_brand_mod.(i).brand_mod_seen > 0 ) then begin |
("", "sr", "eMule mods statistics are disabled, to activate set emule_mods_count true in the \\<a href=\\\"/submit?q=voo+8\\\"\\>misc options\\</a\\> tab." ); |
140 |
incr counter; |
]; |
141 |
Printf.bprintf buf "\\<tr class=\\\"%s\\\"\\>" (if (!counter mod 2 == 0) then "dl-1" else "dl-2"); |
Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>\n" |
142 |
Printf.bprintf buf " |
end else |
143 |
\\<td class=\\\"sr\\\"\\>%s\\</td\\> |
Printf.bprintf buf "eMule mods statistics are disabled, to activate set emule_mods_count true \n" |
144 |
\\<td class=\\\"sr \\\"\\>:\\</td\\> |
|
145 |
\\<td class=\\\"sr ar\\\"\\>%d\\</td\\> |
end |
146 |
\\<td class=\\\"srp \\\"\\>(%.f%%)\\</td\\> |
|
147 |
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
let print_stats o style mods = |
148 |
|
let buf = o.conn_buf in |
149 |
\\<td class=\\\"sr ar\\\"\\>%d\\</td\\> |
|
150 |
\\<td class=\\\"srp \\\"\\>(%.f%%)\\</td\\> |
let u1 = BasicSocket.last_time () - !start_session in |
151 |
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
let u2 = (guptime() + u1) in |
152 |
|
|
153 |
\\<td class=\\\"sr ar\\\"\\>%d\\</td\\> |
let t1 = build_title "eDonkey" "Session" u1 in |
154 |
\\<td class=\\\"srp\\\"\\>(%.0f%%)\\</td\\> |
let t2 = build_title "eDonkey" "Total" u2 in |
155 |
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
|
156 |
|
let l = brand_list in |
157 |
\\<td class=\\\"sr ar\\\"\\>%s\\</td\\> |
|
158 |
\\<td class=\\\"srp \\\"\\>(%.0f%%)\\</td\\> |
if mods then print_stats_mods o style else |
159 |
\\<td class=\\\"sr ar\\\"\\>%.1f\\</td\\> |
match style with |
160 |
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
| Old -> print_stats_old buf stats_array l t1 u1 |
161 |
|
| _ -> |
162 |
\\<td class=\\\"sr ar\\\"\\>%s\\</td\\> |
if use_html_mods o then begin |
163 |
\\<td class=\\\"srp \\\"\\>(%.0f%%)\\</td\\> |
print_stats_html_mods buf stats_array l t1 u1; |
164 |
\\<td class=\\\"sr ar \\\"\\>%.1f\\</td\\> |
print_stats_html_mods buf !!gstats_array l t2 u2 |
165 |
\\<td class=\\\"sr \\\"\\>|\\</td\\> |
end else begin |
166 |
|
print_stats_ascii buf stats_array l t1 u1; |
167 |
\\<td class=\\\"sr \\\"\\>1:%.2f\\</td\\> |
print_stats_ascii buf !!gstats_array l t2 u2 |
168 |
|
end |
|
\\</tr\\>\n" |
|
|
|
|
|
(if !showTotal then "Total" else (brand_mod_to_string (brand_mod_of_int i)) ) |
|
|
|
|
|
(if !showTotal then gstats_all.brand_mod_seen else !!gstats_by_brand_mod.(i).brand_mod_seen) |
|
|
|
|
|
(if !showTotal then 100. else (percent_of_ints (!!gstats_by_brand_mod.(i).brand_mod_seen) gstats_all.brand_mod_seen)) |
|
|
|
|
|
(if !showTotal then gstats_all.brand_mod_filerequest else !!gstats_by_brand_mod.(i).brand_mod_filerequest) |
|
|
|
|
|
(if !showTotal then 100. else (percent_of_ints (!!gstats_by_brand_mod.(i).brand_mod_filerequest) gstats_all.brand_mod_filerequest)) |
|
|
|
|
|
(if !showTotal then gstats_all.brand_mod_banned else !!gstats_by_brand_mod.(i).brand_mod_banned) |
|
|
|
|
|
(max 0.0 (if !showTotal then (percent_of_ints gstats_all.brand_mod_banned |
|
|
gstats_all.brand_mod_seen) else (percent_of_ints (!!gstats_by_brand_mod.(i).brand_mod_banned) gstats_all.brand_mod_banned))) |
|
169 |
|
|
170 |
(size_of_int64 (if !showTotal then gstats_all.brand_mod_upload else !!gstats_by_brand_mod.(i).brand_mod_upload)) |
let _ = |
171 |
|
network.op_network_display_stats <- (fun buf o -> print_stats o New false); |
172 |
|
|
173 |
(if !showTotal then 100. else (max 0.0 (percent_of_int64s |
register_commands |
174 |
(!!gstats_by_brand_mod.(i).brand_mod_upload) gstats_all.brand_mod_upload))) |
[ |
175 |
|
"client_stats", "Network/Donkey",Arg_none (fun o -> |
176 |
|
print_stats o Old false; |
177 |
|
"" |
178 |
|
), ":\t\t\t\tshow breakdown of download/upload by clients brand"; |
179 |
|
|
180 |
(if !showTotal then ((Int64.to_float gstats_all.brand_mod_upload) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
"cs", "Network/Donkey",Arg_none (fun o -> |
181 |
else ((Int64.to_float (!!gstats_by_brand_mod.(i).brand_mod_upload)) /. (float_of_int (guptime() + uptime)) /. 1024.0)) |
print_stats o New false; |
182 |
|
"" |
183 |
|
), ":\t\t\t\t\tshow table of download/upload by ED2K clients brand"; |
184 |
|
|
185 |
(size_of_int64 (if !showTotal then gstats_all.brand_mod_download else !!gstats_by_brand_mod.(i).brand_mod_download)) |
"csm", "Network/Donkey",Arg_none (fun o -> |
186 |
|
print_stats o New true; |
187 |
|
"" |
188 |
|
), ":\t\t\t\t\tshow table of download/upload by eMule MODs"; |
189 |
|
"reset_stats", "Network/Donkey",Arg_none (fun o -> |
190 |
|
|
191 |
(if !showTotal then 100. else (max 0.0 (percent_of_int64s |
Array.iteri (fun x _ -> |
192 |
(!!gstats_by_brand_mod.(i).brand_mod_download) gstats_all.brand_mod_download))) |
stats_array.(x).brand_seen <- 0; |
193 |
|
stats_array.(x).brand_banned <- 0; |
194 |
|
stats_array.(x).brand_filerequest <- 0; |
195 |
|
stats_array.(x).brand_download <- 0L; |
196 |
|
stats_array.(x).brand_upload <- 0L; |
197 |
|
) stats_array; |
198 |
|
|
199 |
|
Array.iteri (fun x _ -> |
200 |
|
stats_mod_array.(x).brand_seen <- 0; |
201 |
|
stats_mod_array.(x).brand_banned <- 0; |
202 |
|
stats_mod_array.(x).brand_filerequest <- 0; |
203 |
|
stats_mod_array.(x).brand_download <- Int64.zero; |
204 |
|
stats_mod_array.(x).brand_upload <- Int64.zero |
205 |
|
) stats_mod_array; |
206 |
|
|
207 |
(if !showTotal then ((Int64.to_float gstats_all.brand_mod_download) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
start_session := BasicSocket.last_time (); |
|
else ((Int64.to_float (!!gstats_by_brand_mod.(i).brand_mod_download)) /. (float_of_int (guptime() + uptime)) /. 1024.0)) |
|
|
|
|
|
(if !showTotal then (if gstats_all.brand_mod_upload = Int64.zero then 0.0 else |
|
|
((Int64.to_float gstats_all.brand_mod_download) /. (Int64.to_float gstats_all.brand_mod_upload) )) else |
|
|
(if !!gstats_by_brand_mod.(i).brand_mod_upload = Int64.zero then 0.0 else |
|
|
( (Int64.to_float !!gstats_by_brand_mod.(i).brand_mod_download) /. |
|
|
(Int64.to_float !!gstats_by_brand_mod.(i).brand_mod_upload) ))) |
|
|
end |
|
|
done; |
|
|
Buffer.add_string buf "\\</table\\>\\</div\\>\n"; |
|
|
end |
|
|
else |
|
|
begin |
|
|
Printf.bprintf buf "eMule Mods - Uptime: %d days, %02dh:%02dm (= %d seconds)\n" |
|
|
days hours mins session_time; |
|
|
Printf.bprintf buf " MOD| seen | Downloads | Uploads | Banned\n"; |
|
|
Printf.bprintf buf "------------+-----------+------------------+------------------+----------\n"; |
|
|
Printf.bprintf buf "%-12s|%6d |%7.1f %5.1f |%7.1f %5.1f |%5d %3.0f%%\n" |
|
|
|
|
|
"Total" |
|
|
mod_stats_all.brand_mod_seen |
|
|
((Int64.to_float mod_stats_all.brand_mod_download) /. 1024.0 /. 1024.0) |
|
|
((Int64.to_float mod_stats_all.brand_mod_download) /. (float_of_int session_time) /. 1024.0) |
|
|
((Int64.to_float mod_stats_all.brand_mod_upload) /. 1024.0 /. 1024.0) |
|
|
((Int64.to_float mod_stats_all.brand_mod_upload) /. (float_of_int session_time) /. 1024.0) |
|
|
mod_stats_all.brand_mod_banned |
|
|
(percent_of_ints mod_stats_all.brand_mod_banned mod_stats_all.brand_mod_seen); |
|
|
|
|
|
for i=1 to brand_mod_count-1 do |
|
|
let brandstr = |
|
|
brand_mod_to_string (brand_mod_of_int i) in |
|
|
|
|
|
Printf.bprintf buf "%-12s|%6d %3.f%%|%7.1f %5.1f %3.0f%%|%7.1f %5.1f %3.0f%%|%5d %3.0f%%\n" |
|
|
(brandstr) |
|
|
stats_by_brand_mod.(i).brand_mod_seen |
|
|
(percent_of_ints stats_by_brand_mod.(i).brand_mod_seen mod_stats_all.brand_mod_seen) |
|
|
((Int64.to_float stats_by_brand_mod.(i).brand_mod_download) /. 1024.0 /. 1024.0) |
|
|
((Int64.to_float stats_by_brand_mod.(i).brand_mod_download) /. (float_of_int session_time) /. 1024.0) |
|
|
(percent_of_int64s stats_by_brand_mod.(i).brand_mod_download mod_stats_all.brand_mod_download) |
|
|
((Int64.to_float stats_by_brand_mod.(i).brand_mod_upload) /. 1024.0 /. 1024.0) |
|
|
((Int64.to_float stats_by_brand_mod.(i).brand_mod_upload) /. (float_of_int session_time) /. 1024.0) |
|
|
(percent_of_int64s stats_by_brand_mod.(i).brand_mod_upload mod_stats_all.brand_mod_upload) |
|
|
stats_by_brand_mod.(i).brand_mod_banned |
|
|
(percent_of_ints stats_by_brand_mod.(i).brand_mod_banned mod_stats_all.brand_mod_banned) |
|
|
done |
|
|
end |
|
|
else |
|
|
if o.conn_output = HTML then |
|
|
begin |
|
|
Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>"; |
|
|
html_mods_table_header buf "emodsTable" "cs" []; |
|
|
Printf.bprintf buf "\\<tr class=\\\"dl-1\\\"\\>"; |
|
|
html_mods_td buf [ |
|
|
("", "sr", |
|
|
"eMule mods statistics are disabled, to activate set emule_mods_count true in the \\<a href=\\\"/submit?q=voo+8\\\"\\>misc options\\</a\\> tab." ); ]; |
|
|
Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>\n" |
|
|
end |
|
|
else |
|
|
Printf.bprintf buf "eMule mods statistics are disabled, to activate set emule_mods_count true \n" |
|
|
|
|
|
let append_out name = |
|
|
open_out_gen [Open_wronly; Open_creat; Open_append; Open_text] 0o666 name |
|
208 |
|
|
209 |
|
"done" |
210 |
|
), ":\t\t\t\t\treset session statistics"; |
211 |
|
] |
212 |
|
|
213 |
(* |
(* |
214 |
let save_download_history file = |
let save_download_history file = |
215 |
|
|
216 |
let buf = Buffer.create 100 in |
let buf = Buffer.create 100 in |
274 |
output_string oc (Buffer.contents buf); |
output_string oc (Buffer.contents buf); |
275 |
close_out oc |
close_out oc |
276 |
*) |
*) |
|
|
|
|
let _ = |
|
|
network.op_network_display_stats <- (fun buf o -> new_print_stats buf o); |
|
|
|
|
|
register_commands |
|
|
[ |
|
|
"client_stats", "Network/Donkey",Arg_none (fun o -> |
|
|
let buf = o.conn_buf in |
|
|
print_stats buf; |
|
|
"" |
|
|
), ":\t\t\t\tshow breakdown of download/upload by clients brand"; |
|
|
|
|
|
"cs", "Network/Donkey",Arg_none (fun o -> |
|
|
let buf = o.conn_buf in |
|
|
new_print_stats buf o; |
|
|
"" |
|
|
), ":\t\t\t\t\tshow table of download/upload by ED2K clients brand"; |
|
|
|
|
|
"csm", "Network/Donkey",Arg_none (fun o -> |
|
|
let buf = o.conn_buf in |
|
|
new_print_mod_stats buf o; |
|
|
"" |
|
|
), ":\t\t\t\t\tshow table of download/upload by eMule MODs"; |
|
|
"reset_stats", "Network/Donkey",Arg_none ( |
|
|
fun o -> |
|
|
|
|
|
Array.iteri ( |
|
|
fun x _ -> |
|
|
stats_by_brand.(x).brand_seen <- 0; |
|
|
stats_by_brand.(x).brand_banned <- 0; |
|
|
stats_by_brand.(x).brand_filerequest <- 0; |
|
|
stats_by_brand.(x).brand_download <- 0L; |
|
|
stats_by_brand.(x).brand_upload <- 0L; |
|
|
) stats_by_brand; |
|
|
|
|
|
Array.iteri ( |
|
|
fun x _ -> |
|
|
stats_by_brand_mod.(x).brand_mod_seen <- 0; |
|
|
stats_by_brand_mod.(x).brand_mod_banned <- 0; |
|
|
stats_by_brand_mod.(x).brand_mod_filerequest <- 0; |
|
|
stats_by_brand_mod.(x).brand_mod_download <- Int64.zero; |
|
|
stats_by_brand_mod.(x).brand_mod_upload <- Int64.zero |
|
|
) stats_by_brand_mod; |
|
|
|
|
|
stats_all.brand_seen <- 0; |
|
|
stats_all.brand_banned <- 0; |
|
|
stats_all.brand_filerequest <- 0; |
|
|
stats_all.brand_download <- 0L; |
|
|
stats_all.brand_upload <- 0L; |
|
|
|
|
|
mod_stats_all.brand_mod_seen <- 0; |
|
|
mod_stats_all.brand_mod_banned <- 0; |
|
|
mod_stats_all.brand_mod_filerequest <- 0; |
|
|
mod_stats_all.brand_mod_download <- Int64.zero; |
|
|
mod_stats_all.brand_mod_upload <- Int64.zero; |
|
|
|
|
|
start_session := last_time (); |
|
|
|
|
|
"done" |
|
|
), ":\t\t\t\t\treset session statistics"; |
|
|
] |
|