多占用系统的IO和硬盘资源,限制用户每天发文文章数,应该修改一下就
可以用了。以下代码在水上明珠上测试。
1、main.c中函数,找到相应位置,
#ifdef CHECK_LESS180SEC
if (abs(time(0)-currentuser.lastlogout)<180&&!HAS_PERM(PERM_SYSOP) &
&
strcasecmp(currentuser.userid, "guest") != 0) {
int tmpnum,tmpnum1;
tmpnum = login_limit();
if (tmpnum==0) //一天60次
{
log_login_limit();
prints("\n对不起,您使用了上站机,一天登入超过了60次!您不能
入本站\n");
prints("若有疑问请通知站务人员, 谢谢.\n");
oflush();
sleep(3);
exit(1);
}
srandom(time(0));
tmpnum = random() % 9;
prints("您在 3 分钟 内重复上站.请按 ^[[1;36m%d^[[m 键确认您的身
? ",tmpnum);
genbuf[0] = igetkey();
if isalnum(genbuf[0])
tmpnum1 = atoi(genbuf);
else
tmpnum1 = tmpnum+1;
if ( tmpnum1 != tmpnum ) {
prints("\n对不起,您并没有按下 %d 键!您不能进入本站\n",tmpn
u
m);
prints("若有疑问请通知站务人员, 谢谢.\n");
oflush();
sleep(3);
exit(1);
}
prints("\n");
}
#endif
2、在main.c中加上login_limit()函数和log_login_limit()函数
// Lotus Add 2001.5.18
int login_limit()
{
FILE *fp;
char buf[100];
int num=0;
struct tm *now;
time_t t;
t = time(0);
now = localtime( &t );
buf[0]='\0';
sprintf(buf,"home/%c/%s/%04d%02d%02d.login",toupper(currentuser.userid[0]),
currentuser.userid,now->tm_year+1900,now->tm_mon+1,now->tm_mday );
if ( !dashf(buf) )
num = 0; //每天第一篇,自动清记录器从0开始
else if((fp=fopen(buf,"r"))!=NULL)
{
fscanf(fp,"%d",&num);
fclose(fp);
}
if (num<0) num=0;
if (num>60)
return 0; //1天最多60次 不允许
else
num++;
if((fp=fopen(buf,"w"))!=NULL)
{
fprintf(fp,"%d",num);
fclose(fp);
}
return num;
}
void
log_login_limit() {
FILE *fp;
time_t t;
t = time(0);
fp=fopen("reclog/limit.login", "a");
fprintf(fp, "%24.24s from:%s \n", ctime(&t),currentuser.userid);
fclose(fp);
}
--
FROM 202.119.118.27