-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnodelist-html.js
215 lines (188 loc) · 5.48 KB
/
nodelist-html.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
// nodelist-html.js
// Synchronet Service for sending a periodic HTML node list
var refresh_rate=10 /* seconds */
var start=new Date();
load("nodedefs.js");
var include_age_gender=true;
var include_location=false;
var include_statistics=false;
// Parse arguments
for(i=0;i<argc;i++)
switch(argv[i].toLowerCase()) {
case "-r":
refresh_rate=Number(argv[++i]);
break;
case "-n":
include_age_gender=false;
break;
case "-l":
include_location=true;
break;
case "-s": /* statistics */
include_statistics=true;
break;
}
if((this.http_request==undefined) && this.server && this.client) {
// Write a string to the client socket
function write(str)
{
client.socket.send(str);
}
function writeln(str)
{
if(str)
write(str + "\r\n");
else
write("\r\n");
}
}
function xtrn_name(code)
{
if(this.xtrn_area==undefined)
return(code);
for(s in xtrn_area.sec_list)
for(p in xtrn_area.sec_list[s].prog_list)
if(xtrn_area.sec_list[s].prog_list[p].code.toLowerCase()==code.toLowerCase())
return(xtrn_area.sec_list[s].prog_list[p].name);
return(code);
}
// Get HTTP Request
while(this.client!=undefined && client.socket.data_waiting) {
request = client.socket.recvline(512 /*maxlen*/, 3 /*timeout*/);
if(request==null)
break;
// log(format("client request: '%s'",request));
}
if(this.server!=undefined) /* !CGI */
writeln("HTTP/1.0 200 OK");
/* send HTTP headers */
writeln("Content-Type: text/html");
writeln();
// HTML Header
writeln("<html>");
writeln("<head>");
writeln(format("<title>%s - Node List</title>",system.name));
writeln(format("<meta http-equiv=refresh content=%d>",refresh_rate));
writeln("</head>");
writeln("<body bgcolor=teal text=white link=yellow vlink=lime alink=white>");
writeln("<font face=Arial,Helvetica,sans-serif>");
// Login Button - Modified by RuneMaster of RuneKeep BBS
writeln("<table border=0 width=100%>");
writeln("<tr>");
writeln("<td align=left>");
writeln(format("<h1>%s - Node List</h1>",system.name.italics()).fontcolor("lime"));
writeln("</td>");
writeln("<td align=right>");
writeln("<form>");
writeln("<input type=button value='Login' onClick='location=\"telnet://"
+ system.host_name + "\";'>");
writeln("</form>");
writeln("</td>");
writeln("</tr>");
writeln("</table>");
font_color = "<font color=black>";
if(include_statistics) {
total = time()-system.uptime;
days = Math.floor(total/(24*60*60));
if(days)
total%=(24*60*60);
hours = Math.floor(total/(60*60));
min = (Math.floor(total/60))%60;
sec = total%60;
// Table
writeln("<table border=1 width=100%>");
writeln("<td>Up Time<td>"
+ format("%u days, %u:%02u:%02u",days,hours,min,sec));
writeln("<td>Logons Today<td>" + system.stats.logons_today);
writeln("<td>Posts Today<td>" + system.stats.messages_posted_today);
writeln("<td>Uploads Today<td>"
+ format("%lu bytes in %lu files"
,system.stats.bytes_uploaded_today
,system.stats.files_uploaded_today));
writeln("<tr>");
writeln("<td>Time-on Today<td>" + system.stats.timeon_today);
writeln("<td>New Users Today<td>" + system.stats.new_users_today);
writeln("<td>Emails Today<td>" + system.stats.email_sent_today);
writeln("<td>Downloads Today<td>"
+ format("%lu bytes in %lu files"
,system.stats.bytes_downloaded_today
,system.stats.files_downloaded_today));
writeln("</table>");
writeln("<br>");
}
// Table
writeln("<table border=0 width=100%>");
// Header
writeln("<thead>");
writeln("<tr bgcolor=white>");
write("<th align=center width=7%>" + font_color + "Node");
write("<th align=center width=20%>" + font_color + "User");
write("<th align=left>" + font_color + "Action/Status");
if(include_location)
write("<th align=left>" +font_color+ "Location");
if(include_age_gender) {
write("<th align=center width=7%>" + font_color + "Age");
write("<th align=center width=10%>" + font_color + "Gender\r\n");
}
write("<th align=center width=10%>" + font_color + "Time\r\n");
writeln("</thead>");
writeln("<tbody>");
var u = new User(0);
for(n=0;n<system.node_list.length;n++) {
write("<tr>");
write(format("<td align=right><font size=-1>%d",n+1));
if(system.node_list[n].status==NODE_INUSE) {
u.number=system.node_list[n].useron;
if(system.node_list[n].action==NODE_XTRN && system.node_list[n].aux)
action=format("running %s",xtrn_name(u.curxtrn));
else
action=format(NodeAction[system.node_list[n].action]
,system.node_list[n].aux);
write(format(
"<td align=center><a href=mailto:%s>%s</a>"
,u.email
,u.alias
));
write(format(
"<td><font color=yellow>%s"
,action
));
if(include_location)
write(format(
"<td align=left>%s"
,u.location
));
if(include_age_gender)
write(format(
"<td align=center>%d<td align=center>%s"
,u.age
,u.gender
));
t=time()-u.logontime;
if(t&0x80000000) t=0;
write(format(
"<td align=center>%u:%02u:%02u"
,Math.floor(t/(60*60))
,Math.floor(t/60)%60
,t%60
));
} else {
action=format(NodeStatus[system.node_list[n].status],system.node_list[n].aux);
write(format("<td><td>%s",action));
}
write("\r\n");
}
writeln("</tbody>");
writeln("</table>");
writeln("<p><font color=silver><font size=-2>");
writeln(format("Auto-refresh in %d seconds",refresh_rate));
write(format("<br>Dynamically generated in %lu milliseconds "
,new Date().valueOf()-start.valueOf()));
write("by ");
if(this.server)
write(server.version + " and ");
write(system.version_notice.link("http://www.synchro.net"));
writeln("<br>" + system.timestr());
writeln("</body>");
writeln("</html>");
/* End of nodelist-html.js */