放出我们站的吧
我们上任维护做的,据说是仿照别的站的代码
#include "bbslib.h"
struct user_info user[MAXACTIVE];
/*
* 10.2.1 - 10.2.234 10.2.33
* 判断是不是在一个网段,返回和开始网段的差+1
*/
int
ipbetween(char *ip1, char *ip2, char *ip3, int len)
{
if (strlen(ip1) < len || strlen(ip2) < len || strlen(ip3) < len)
return 0;
if (strncmp(ip1, ip2, len) || strncmp(ip1, ip3, len))
return 0;
if (atoi(ip1 + len) <= atoi(ip3 + len)
&& atoi(ip2 + len) >= atoi(ip3 + len))
return atoi(ip1 + len) - atoi(ip3 + len) + 1;
else
return 0;
}
int
bbsuserinfo_main()
{
int i, start, total = 0, fh, shmkey, shmid;
struct user_info *x;
int cOutCAU = 0, cInCAU = 0, cWest = 0, cEast = 0, cNotknow = 0;
int mWeb = 0, mTelnet = 0;
int mcInWeb = 0, mcOutWeb = 0;
int mcInTelnet = 0, mcOutTelnet = 0;
int xq160 = 0, xq170 = 0, xq1 = 0, xq10 = 0, xq20 = 0, xq30 = 0, xq40 =
0, xq50 = 0, xq60 = 0, xq70 = 0, xq80 = 0, xq90 = 0, xq100 =
0, xq110 = 0;
int dq80 = 0, dq90 = 0, dq150 = 0, dq160 = 0, dq170 = 0, dq200 =
0, dq210 = 0, dq220 = 0, dq230 = 0;
char search;
html_header(1);
check_msg();
changemode(LUSERS);
printf("<body><center>\n");
for (i = 0; i < MAXACTIVE; i++) {
x = &(shm_utmp->uinfo[i]);
if (x->active == 0)
continue;
//if (x->invisible) //&& !HAS_PERM(PERM_SEECLOAK))
// continue;
memcpy(&user[total], x, sizeof (struct user_info));
total++;
}
printf("%s -- 在线用户分布统计 [在线总人数: %d人]<hr>\n", BBSNAME,
count_online());
for (i = 0; i < total; i++) {
if (ipbetween("202.205.80", "202.205.95", user[i].from, 8)) {
dq80++;
cInCAU++;
if (user[i].pid == 1)
mcInWeb++;
else
mcInTelnet++;
} else
if (ipbetween
("202.112.160", "202.112.175", user[i].from, 8)) {
xq160++;
cInCAU++;
if (user[i].pid == 1)
mcInWeb++;
else
mcInTelnet++;
} else if (ipbetween("10.2.1", "10.2.111", user[i].from, 5)) {
xq1++;
cInCAU++;
if (user[i].pid == 1)
mcInWeb++;
else
mcInTelnet++;
} else if (ipbetween("10.2.150", "10.2.203", user[i].from, 5)) {
dq150++;
cInCAU++;
if (user[i].pid == 1)
mcInWeb++;
else
mcInTelnet++;
} else if (ipbetween("10.2.210", "10.2.232", user[i].from, 5)) {
dq210++;
cInCAU++;
if (user[i].pid == 1)
mcInWeb++;
else
mcInTelnet++;
} else {
cOutCAU++;
if (user[i].pid == 1)
mcOutWeb++;
else
mcOutTelnet++;
}
#if 0
if (!strncmp(user[i].from, "202.112.16", 10)) {//202.112.160 -169 西校区网络中心等
xq160++;
cInCAU++;
if (user[i].pid == 1)
mcInWeb++;
else
mcInTelnet++;
} else if (!strncmp(user[i].from, "202.112.17", 10)) {//202.112.170 -179 西校区网络中心等
xq170++;
cInCAU++;
if (user[i].pid == 1)
mcInWeb++;
else
mcInTelnet++;
} else if (!strncmp(user[i].from, "202.205.8", 9)) {
dq80++;
cInCAU++;
if (user[i].pid == 1)
mcInWeb++;
else
mcInTelnet++;
} else if (!strncmp(user[i].from, "202.205.9", 9)) {
dq90++;
cInCAU++;
if (user[i].pid == 1)
mcInWeb++;
else
mcInTelnet++;
} else if (!strncmp(user[i].from, "10.2.", 5)) {
cInCAU++;
if (user[i].pid == 1)
mcInWeb++;
else
mcInTelnet++;
} else {
cOutCAU++;
if (user[i].pid == 1)
mcOutWeb++;
else
mcOutTelnet++;
}
if (!strncmp(user[i].from, "10.2.210.", 9) ||
!strncmp(user[i].from, "10.2.211.", 9) ||
!strncmp(user[i].from, "10.2.212.", 9) ||
!strncmp(user[i].from, "10.2.213.", 9) ||
!strncmp(user[i].from, "10.2.214.", 9) ||
!strncmp(user[i].from, "10.2.215.", 9) ||
!strncmp(user[i].from, "10.2.216.", 9) ||
!strncmp(user[i].from, "10.2.217.", 9) ||
!strncmp(user[i].from, "10.2.218.", 9) ||
!strncmp(user[i].from, "10.2.219.", 9) ||
!strncmp(user[i].from, "10.2.220.", 9) ||
!strncmp(user[i].from, "10.2.221.", 9) ||
!strncmp(user[i].from, "10.2.222.", 9) ||
!strncmp(user[i].from, "10.2.223.", 9) ||
!strncmp(user[i].from, "10.2.224.", 9) ||
!strncmp(user[i].from, "10.2.225.", 9) ||
!strncmp(user[i].from, "10.2.226.", 9) ||
!strncmp(user[i].from, "10.2.227.", 9) ||
!strncmp(user[i].from, "10.2.228.", 9) ||
!strncmp(user[i].from, "10.2.229.", 9) ||
!strncmp(user[i].from, "10.2.230.", 9) ||
!strncmp(user[i].from, "10.2.231.", 9) ||
!strncmp(user[i].from, "10.2.232.", 9))
girl++;
#endif
if (user[i].pid == 1)
mWeb++;
else
mTelnet++;
}
printf("<table border=0 width=%%100>\n");
printf
("<tr class=pt9 bgcolor=#039003><td><font color=white>农大校内用户 </font><td><font color=white> %4d",
cInCAU);
printf
("<tr class=pt9lc><td> Telnet用户<td> %4d",
mcInTelnet);
printf
("<tr class=pt9dc><td> WWW用户<td> %4d",
mcInWeb);
printf("<tr class=pt9lc><td> <td>  ");
printf
("<tr class=pt9 bgcolor=#039003><td><font color=white>校外用户 </font><td><font color=white> %4d",
cOutCAU);
printf
("<tr class=pt9lc><td> Telnet用户<td> %4d",
mcOutTelnet);
printf
("<tr class=pt9dc><td> WWW用户<td> %4d",
mcOutWeb);
printf("<tr class=pt9lc><td> <td>  ");
printf
("<tr class=pt9 bgcolor=#039003><td><font color=white>合计:</font> <td><font color=white> %4d",
mTelnet + mWeb);
printf
("<tr class=pt9lc><td> Telnet用户合计<td> %4d",
mTelnet);
printf
("<tr class=pt9dc><td> WWW用户合计<td> %4d",
mWeb);
printf("<tr class=pt9lc><td> <td>  ");
printf
("<tr class=pt9 bgcolor=#039003><td><font color=white>分段统计:</font> <td><font color=white> ");
printf
("<tr class=pt9lc><td> 202.112.160-175用户合计<td> %4d",
xq160);
printf
("<tr class=pt9lc><td> 202.205.80.-95用户合计<td> %4d",
dq80);
printf
("<tr class=pt9lc><td> 10.2.1-111用户合计<td> %4d",
xq1);
printf
("<tr class=pt9lc><td> 10.2.150.-203用户合计<td> %4d",
dq150);
printf
("<tr class=pt9lc><td> 10.2.210-232用户合计<td> %4d",
dq210);
printf
("<tr class=pt9lc><td> 东区:西区<td> %4d :%4d",
dq80 + dq150 + dq210, xq1 + xq160);
printf("</tr></table><br><hr>");
printf("</tr></table><br><hr>");
printf("[<a href='javascript:history.go(-1)'>返回</a>] ");
printf("</center>\n");
http_quit();
return 0;
}
【 在 chutium@smth.org-SPAM.no (阿新) 的大作中提到: 】
: 在线分布统计么?那能不能放出来个代码?找了好久都没见……
: 【 在 朱雀.bbs@wusetu.cn (无家可归|流浪......) 的大作中提到: 】
: : 这个我们站也有
: : 用的是别人的代码
--
FROM 10.2.168.205