BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / bbs-man-dev / #4079同步于 1 周前
BBSMan_Dev机器人发帖

实现查询大于指定天数未上线用户功能遇到的问题

pplong2000.
1 周前镜像同步6 回复
转信站: BYR!news.cn99.com!news.newsmth.net!NEWSMTH 我编写的程序如下:(在libBBS/ucache.c中,在头文件中声明了的) int searchunday(long daynum) { int j; FILE *fp,*fpp; struct userec user; fpp =fopen("/usr/local/bbs/.PASSWDS","rb");//安装目录 fp =fopen("/home/bbs/result.txt","a+"); if(fp=NULL)return 0; j =0; while(!feof(fpp)) { fread(&user, sizeof(user), 1, fpp); if((time((time_t *)NULL)-user.lastlogin)/(24*60*60)>=daynum) { fwrite(&user,sizeof(user),1,fp); j=j+1; } } fclose(fp); fclose(fpp); return j; } 在phplib/phpbbs.user.c中加了: PHP_FUNCTION(bbs_getunday) { long s; long num; if (zend_parse_parameters(1 TSRMLS_CC, "l", &s) != SUCCESS) { WRONG_PARAM_COUNT; } num =searchunday(s); RETURN_LONG(num); } 在phplib/phpbbs.user.h中加了: PHP_FUNCTION(bbs_getunday); PHP_FE(bbs_getunday, NULL) \ 但是调用的时候出现问题,函数是可以调用的,因为那个result.txt文件创建了,但是里面没有内容,而且在php代码中调用bbs_getunday没有返回值,是怎么回事啊!大家帮忙分析一下.
订阅后,新回复会通过你的通知中心匿名送达。
6 条回复
atppp.机器人#1 · 1 周前
转信站: BYR!news.cn99.com!news.newsmth.net!NEWSMTH 没判断user.userid[0]是不是\0 你确定result.txt是空文件?还是最开始有很多空行? 【 在 pplong2000 (hiker) 的大作中提到: 】 : 我编写的程序如下:(在libBBS/ucache.c中,在头文件中声明了的) : int searchunday(long daynum) : { : int j; : FILE *fp,*fpp; : struct userec user; : fpp =fopen("/usr/local/bbs/.PASSWDS","rb");//安装目录 : fp =fopen("/home/bbs/result.txt","a+"); : if(fp=NULL)return 0; : j =0; : while(!feof(fpp)) : { fread(&user, sizeof(user), 1, fpp); : if((time((time_t *)NULL)-user.lastlogin)/(24*60*60)>=daynum) : { : fwrite(&user,sizeof(user),1,fp); : j=j+1; : } : } : fclose(fp); : fclose(fpp); : return j; : } : 在phplib/phpbbs.user.c中加了: : PHP_FUNCTION(bbs_getunday) : { : long s; : long num; : if (zend_parse_parameters(1 TSRMLS_CC, "l", &s) != SUCCESS) { : WRONG_PARAM_COUNT; : } : num =searchunday(s); : RETURN_LONG(num); : } : 在phplib/phpbbs.user.h中加了: : PHP_FUNCTION(bbs_getunday); : PHP_FE(bbs_getunday, NULL) \ : 但是调用的时候出现问题,函数是可以调用的,因为那个result.txt文件创建了,但是里面没有内容,而且在php代码中调用bbs_getunday没有返回值,是怎么回事啊!大家帮忙分析一下.
atppp.机器人#2 · 1 周前
转信站: BYR!news.cn99.com!news.newsmth.net!NEWSMTH [bbs@raid test]$ cat unday.c #include "bbs.h" static int searchunday(struct userec *user, void* arg) { int d = (int)arg; if (user->userid[0] && (time(NULL) - user->lastlogin)>=d*86400) { printf("%s\n",user->userid); } return 0; } int main(int argc, char** argv) { int d; if (argc != 2) return 0; d = atoi(argv[1]); init_all(); apply_users(searchunday, (void*)d); } [bbs@raid test]$ alias kgcc alias kgcc='gcc -I/home/bbs/src/build -I/home/bbs/src/kbs_bbs/src -I/usr/include/mysql -lBBS -lsystem -L/home/bbs/lib' [bbs@raid test]$ kgcc unday.c -o unday [bbs@raid test]$ ./unday 100 SYSOP 【 在 pplong2000 (hiker) 的大作中提到: 】 : 我编写的程序如下:(在libBBS/ucache.c中,在头文件中声明了的) : int searchunday(long daynum) : { : ...................
jiangjun2000机器人#3 · 1 周前
转信站: BYR!news.cn99.com!news.newsmth.net!NEWSMTH init_all()是干嘛的来着 我记得你说过这个函数不能随便加, 位置不好的话就会把整个数据搞坏 【 在 atppp (Big Mouse) 的大作中提到: 】 : [bbs@raid test]$ cat unday.c : #include "bbs.h" : static int searchunday(struct userec *user, void* arg) { : ...................
pplong2000.机器人#4 · 1 周前
转信站: BYR!news.cn99.com!news.newsmth.net!NEWSMTH 就是,那个函数是什么功能啊?还有atppp大大有没有开发php扩展的经验啊?都有哪几个地方需要更改啊??
sxdxsimple.机器人#5 · 1 周前
转信站: BYR!news.cn99.com!news.newsmth.net!NEWSMTH 不敢用 【 在 atppp (Big Mouse) 的大作中提到: 】 : [bbs@raid test]$ cat unday.c : #include "bbs.h" : static int searchunday(struct userec *user, void* arg) { : ...................
sxdxsimple.机器人#6 · 1 周前
转信站: BYR!news.cn99.com!news.newsmth.net!NEWSMTH 直接看init_all()函数吧, 用点逆向方法 【 在 jiangjun2000 (%d) 的大作中提到: 】 : init_all()是干嘛的来着 : 我记得你说过这个函数不能随便加, 位置不好的话就会把整个数据搞坏