-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslog.js
95 lines (80 loc) · 2.16 KB
/
slog.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
(function() {
writeln("\r\nSynchronet System/Node Statistics Log Viewer\n");
var sfile = new File(system.ctrl_dir + "csts.dab");
var list = [];
var reverse = false;
var show_totals = false;
var total_logons = 0;
var total_timeon = 0;
var total_uls = 0;
var total_ulb = 0;
var total_dls = 0;
var total_dlb = 0;
var total_posts = 0;
var total_emails = 0;
var total_fbacks = 0;
while(argv.length > 0) {
switch(argv.shift().toUpperCase()) {
case "/REVERSE":
case "/R":
reverse = true;
break;
case "/TOTALS":
case "/T":
show_totals = true;
break;
}
}
if(!file_exists(sfile.name)) {
writeln("* " + sfile.name + " does not exist");
return false;
}
if(!sfile.open('r+b')) {
writeln("* error opening " + sfile.name);
return false;
}
while(sfile.position <= file_size(sfile.name) - 40) {
var timestamp = sfile.readBin();
var logons = sfile.readBin();
var timeon = sfile.readBin();
var uls = sfile.readBin();
var ulb = sfile.readBin();
var dls = sfile.readBin();
var dlb = sfile.readBin();
var posts = sfile.readBin();
var emails = sfile.readBin();
var fbacks = sfile.readBin();
if(show_totals) {
total_logons += logons;
total_timeon += timeon;
total_uls += uls;
total_ulb += uls;
total_dls += uls;
total_dlb += uls;
total_posts += posts;
total_emails += emails;
total_fbacks += fbacks;
}
list.unshift(
strftime("%x",timestamp-(24*60*60)) +
format(" T:%5lu L:%3lu P:%3lu E:%3lu F:%3lu U:%6luk %3lu D:%6luk %3lu",
timeon,logons,posts,emails,fbacks,ulb/1024,uls,dlb/1024,dls)
);
}
sfile.close();
if(reverse)
list.reverse();
for each(var i in list)
writeln(i);
if(show_totals) {
writeln("");
writeln(format("%-*s: %d",20,"Total Time",total_timeon));
writeln(format("%-*s: %d",20,"Total Logons",total_logons));
writeln(format("%-*s: %d - %dk",20,"Total U/L",total_uls, total_ulb));
writeln(format("%-*s: %d - %dk",20,"Total D/L",total_dls, total_dlb));
writeln(format("%-*s: %d",20,"Total Posts",total_posts));
writeln(format("%-*s: %d",20,"Total E-Mails",total_emails));
writeln(format("%-*s: %d",20,"Total Feedback",total_fbacks));
}
writeln("");
})();