📄 jingcai.c
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <unistd.h>#include "../../nju09/usesql.h"#include "mysql/mysql.h"#include "../../include/bbs.h"#include "../../libythtbbs/article.h" //评价文章的人数#define pingjiarenshu 2//近期时间 秒为单位 比如近期为7天则如下#define jinrishijian 7*24*3600int main(void){ MYSQL *mysql=NULL; MYSQL_ROW row; MYSQL_RES *res; FILE *fp1,*fp2; char sqlbuf[512],fname[200],buff[500]; int qryflag; time_t curtime; struct fileheader *fh; curtime=time(NULL); fh=(struct fileheader *)malloc(sizeof(struct fileheader)); mysql=mysql_init(mysql); mysql=mysql_real_connect(mysql,"localhost",SQLUSER, SQLPASSWD, SQLDB,0, NULL,0); if (!mysql) { exit(0); } sprintf(sqlbuf,"select avg(class),count(filename) as cnt,board,mid(filename,3,10) as tt from articlevote group by filename having cnt>=%d and %ld- tt<%d ",pingjiarenshu,curtime,jinrishijian ); qryflag=mysql_query(mysql,sqlbuf); res=mysql_store_result(mysql); if((fp2=fopen( MY_BBS_HOME "/wwwtmp/navpart.txt","w"))==NULL){ printf("Cannot create file " MY_BBS_HOME "/wwwtmp/navpart.txt\n"); exit(0); } while((row = mysql_fetch_row(res))){ int ff=0; sprintf(fname,MY_BBS_HOME "/boards/%s/.DIR",row[2]); if((fp1=fopen(fname,"r"))==NULL){ printf("Cannot open file %s\n",fname); exit(0); } while(!feof(fp1)){ fread( fh,1,sizeof(struct fileheader),fp1); if(fh->filetime==atoi(row[3])){ ff=1; break; } } sprintf(buff,"%s %s %s %s %d %s\n",row[0],row[1],row[2],fh->owner,fh->thread,fh->title); fputs(buff,fp2); fclose(fp1); } fclose(fp2); mysql_close(mysql); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -