diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-03-07 23:13:44 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-03-07 23:13:44 +0800 |
commit | ae31e19f92e717919ac8e3db9039eb38d2b89aae (patch) | |
tree | c70164d6a1852344f44b04a653ae2815043512af /util/smtest.temp | |
download | pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.gz pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.bz2 pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.lz pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.xz pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.zst pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.zip |
Initial revision
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/smtest.temp')
-rw-r--r-- | util/smtest.temp | 231 |
1 files changed, 231 insertions, 0 deletions
diff --git a/util/smtest.temp b/util/smtest.temp new file mode 100644 index 00000000..7daa12ce --- /dev/null +++ b/util/smtest.temp @@ -0,0 +1,231 @@ +#include <stdio.h> +#include <sys/types.h> +#include <unistd.h> +#include <string.h> +#include <stdlib.h> +#include <time.h> +#include <ctype.h> +#include "config.h" +#include "pttstruct.h" +#include "util.h" +#include "perm.h" +#include "common.h" +#include "proto.h" + +#define OUTFILE BBSHOME "/pttbbs/util/smtest.result1" +#define FIREFILE BBSHOME "/pttbbs/util/smtest.result2" + +extern boardheader_t *bcache; +extern int numboards; + +boardheader_t allbrd[MAX_BOARD]; +struct userec_t xuser; + +int getuser(char *userid) { + int uid; + if((uid = searchuser(userid))) + passwd_query(uid, &xuser); + return uid; +} + +int LINK(char* src, char* dst){ + char cmd[200]; + + if( link(src, dst) == 0){ + return 0; + } + + sprintf(cmd, "/bin/cp -R %s %s", src, dst); + return system(cmd); +} + +int outofdate(char *hdrdate, char latestdate[]) +{ + int k,rr; + char *dd; + + dd = strtok(hdrdate,"/"); + + if(dd){ + k = 0; + do + { + if (*dd == '[' ){dd[strlen(dd)-1]='\0'; dd++;} + rr = atoi(dd); + printf("%d/", rr); + } while((dd = strtok(NULL,"/")) != NULL); + } + + printf("\n"); + + if(1) + return 1; + else + return 0; +} + +int main() +{ + int bmid, i, j, k, rd,rr; + char *p, *bmsname[3], fname[256], *dd; + fileheader_t hdr; + FILE *inf; + + /* set date */ + char thedate[5]; + time_t t = time(NULL); + struct tm *tm = localtime(&t); + + sprintf(thedate, "%2d/%02d", tm->tm_mon + 1, tm->tm_mday); + + resolve_boards(); + if(passwd_mmap()) + exit(1); + memcpy(allbrd,bcache,numboards*sizeof(boardheader_t)); + /* write out the target file */ + inf = fopen(OUTFILE, "w+"); + if(inf == NULL){ + printf("open file error : %s\n", OUTFILE); + exit(1); + } + + /*the ouput table title*/ + fprintf(inf,"英文版名 類別 中文版名 版主名單" + " 日期 備註 \n"); + + j = 0 ; + for (i = 0; i < 30; i++) { + rd = 0; + if(allbrd[i].brdname[0] == '\0') continue; + if((allbrd[i].brdattr & BRD_NOZAP) == 1) continue; + + sprintf(fname, BBSHOME "/boards/%s/.DIR",allbrd[i].brdname); + + /* get date to choose junk board */ + + rd = get_num_records(fname, sizeof(fileheader_t)); + get_record(fname, &hdr, sizeof (hdr), rd - 30); + + + if(outofdate(hdr.date,thedate)) printf("yest\n"); + +/* + dd = strtok(hdr.date,"/"); + + if(dd){ + k = 0; + do + { + if (*dd == '[' ){dd[strlen(dd)-1]='\0'; dd++;} + rr = atoi(dd); + printf("%d/", rr); + + } while((dd = strtok(NULL,"/")) != NULL); + } + printf("\n"); +*/ + /* print to file */ + printf("%-*.*s%-*.*s%-*.*s%-*.*s", IDLEN, IDLEN, allbrd[i].brdname, + BTLEN-24, BTLEN-26, allbrd[i].title, IDLEN - 5, IDLEN-5,hdr.date, + IDLEN * 3, IDLEN * 3, allbrd[i].BM); + + /* post to board */ + + + + /* user extract to mail */ + + p=strtok(allbrd[i].BM,"/ "); + if(p){ + k = 0; + do + { + if (*p == '[' ){p[strlen(p)-1]='\0'; p++;} + bmid=getuser(p); + bmsname[k] = p; + if(isalpha(allbrd[i].BM[0])&& !(xuser.userlevel &PERM_SYSOP)) + { + // printf("%s", bmsname[k]); + } + k++; + } while((p=strtok(NULL,"/ "))!=NULL); + } + + printf("\n"); + +} + + +/* + + + + if(flag == 1){ + bmbuf[0] = '\0'; + for(k = 0 , n = 0; k < index; k++){ + if(!bms[k].flag){ + if( n++ != 0) strcat(bmbuf, "/"); + strcat(bmbuf, bms[k].bmname); + } + } + strcpy(bcache[i].BM, bmbuf); + } + } + qsort(lostbms, j, sizeof(lostbm), bmlostdays_cmp); + + //write to the etc/toplazyBM + for ( i=0; i<j; i++) + { + if( lostbms[i].lostdays > 60){ + fprintf(firef, "%-*.*s%-*.*s%-*.*s%3d天沒上站\n", IDLEN, IDLEN, lostbms[i].title, + BTLEN-10, BTLEN-10, lostbms[i].ctitle, IDLEN,IDLEN, + lostbms[i].bmname,lostbms[i].lostdays); + }else{ + fprintf(inf, "%-*.*s%-*.*s%-*.*s%3d天沒上站\n", IDLEN, IDLEN, lostbms[i].title, + BTLEN-10, BTLEN-10, lostbms[i].ctitle, IDLEN,IDLEN, + lostbms[i].bmname,lostbms[i].lostdays); + } + } + fclose(inf); + fclose(firef); + + //printf("Total %d boards.\n", count); + + //mail to the users + for( i=0; i<j; i++) + { + fileheader_t mymail; + char genbuf[200]; + int lostdays; + + lostdays = lostbms[i].lostdays; + + if( (lostdays != 30) && (lostdays != 45) && (lostdays <= 60)) + continue; + + sprintf(genbuf, BBSHOME "/home/%c/%s", lostbms[i].bmname[0], lostbms[i].bmname); + stampfile(genbuf, &mymail); + + strcpy(mymail.owner, "[PTT警察局]"); + + if(lostdays <= 60){ + sprintf(mymail.title, + "\033[32m [版主免職警告通知] \033[m %s BM %s", lostbms[i].title, lostbms[i].bmname); + }else{ + sprintf(mymail.title, + "\033[32m [版主免職通知] \033[m %s BM %s", lostbms[i].title, lostbms[i].bmname); + } + mymail.savemode = 0 ; + unlink(genbuf); + if(lostdays <= 60){ + LINK(OUTFILE, genbuf); + }else{ + LINK(FIREFILE, genbuf); + } + + sprintf(genbuf, BBSHOME "/home/%c/%s/.DIR", lostbms[i].bmname[0], lostbms[i].bmname); + append_record(genbuf, &mymail, sizeof(mymail)); + } +*/ + return 0; +} |