From 045a8f57c5729d9df26a0b7cfc9f07b49bfe10bc Mon Sep 17 00:00:00 2001 From: in2 Date: Thu, 15 May 2003 08:20:37 +0000 Subject: remove smtest git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@848 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/smtest.c | 289 ---------------------------------------------------- util/smtest.c.save | 172 ------------------------------- util/smtest.result1 | 191 ---------------------------------- util/smtest.result2 | 3 - util/smtest.temp | 231 ----------------------------------------- 5 files changed, 886 deletions(-) delete mode 100644 util/smtest.c delete mode 100644 util/smtest.c.save delete mode 100644 util/smtest.result1 delete mode 100644 util/smtest.result2 delete mode 100644 util/smtest.temp diff --git a/util/smtest.c b/util/smtest.c deleted file mode 100644 index e46157f2..00000000 --- a/util/smtest.c +++ /dev/null @@ -1,289 +0,0 @@ -/* $Id: smtest.c,v 1.5 2002/06/19 13:38:01 lwms Exp $ */ -#include "bbs.h" - -#define WARNFILE BBSHOME "/etc/DeleteBoard.warn" -#define EXECFILE BBSHOME"/etc/DeleteBoard.exec" -#define WARNLIST BBSHOME"/etc/DeleteBoardList.warn" -#define EXECLIST BBSHOME"/etc/DeleteBoardList.exec" - -extern boardheader_t *bcache; -extern int numboards; - -boardheader_t allbrd[MAX_BOARD]; -extern userec_t xuser; - - -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 thedate[], int *zf) -{ - int k = 0; - char *dd; - char latestdate[6]; - int date1[2], date2[2],datetemp; - *zf = 0; - - strcpy(latestdate, thedate); - - dd = strtok(hdrdate,"/"); - if(dd == NULL) return 2; - if(dd) - k = 0; - do{ - if (*dd == '[' ){dd[strlen(dd)-1]='\0'; dd++;} - date1[k] = atoi(dd); - k++; - } while((dd=strtok(NULL,"/ "))!=NULL); - - dd = strtok(latestdate,"/"); - if(dd) - k = 0; - do{ - if (*dd == '[' ){dd[strlen(dd)-1]='\0'; dd++;} - date2[k] = atoi(dd); - k++; - } while((dd=strtok(NULL,"/ "))!=NULL); - - if(date2[0] == date1[0] && date2[1] >= date1[1]) - return 0; - - datetemp = date2[0]; - - for(k = 1;k <= 5;k++) - { - datetemp -= 1; - if((datetemp) <= 0){ - datetemp = 12; - } - if(k < 3 && datetemp == date1[0]) return 0; - if(k == 3 && datetemp == date1[0] && date2[1] <= date1[1]) return 0; - if(k == 3 && datetemp == date1[0] && date2[1] > date1[1]) return 1; - if(k == 4 && datetemp == date1[0] && date2[1] > date1[1]) return 1; - } - *zf = 1; - return 1; -} - -void mailtouser(char *bmname, char *bname, int zf) -{ - fileheader_t mymail; - char genbuf[200]; - - sprintf(genbuf, BBSHOME "/home/%c/%s", bmname[0], bmname); - stampfile(genbuf, &mymail); - strcpy(mymail.owner, "[PTTĵ¹î§½]"); - - if(zf == 0){ - sprintf(mymail.title,"\033[32m [¼oªOĵ§i³qª¾]" - "\033[m %sªO(BM:%s)",bname, bmname); - }else{ - sprintf(mymail.title,"\033[32m [¼oªO³qª¾] " - "\033[m %sªO(BM:%s)",bname, bmname); - } - unlink(genbuf); - if(zf == 0){ - LINK(WARNFILE, genbuf); - }else{ - LINK(EXECFILE, genbuf); - } - - sprintf(genbuf, BBSHOME "/home/%c/%s/.DIR", bmname[0], bmname); - append_record(genbuf, &mymail, sizeof(mymail)); -} - -int main() -{ - int bmid, i, j, k, rd, ood, flag, zapflag = 0,warncount = 0,execcount = 0; - char *p, *bmsname[3], fname[256], hdrdatetemp[6],thedate[6]; - char bname[32],genbuf[200]; - fileheader_t hdr; - FILE *inf, *def; - - ///// set date ////// - time_t t = time(NULL); - struct tm *tm = localtime(&t); - sprintf(thedate, "%2d/%02d", tm->tm_mon + 1, tm->tm_mday); - - ////// board ////// - - resolve_boards(); - if(passwd_mmap()) - exit(1); - memcpy(allbrd,bcache,numboards*sizeof(boardheader_t)); - - ////// write out the target file ////// - inf = fopen(WARNLIST, "w+"); - if(inf == NULL){ - printf("open file error : %s\n", WARNLIST); - exit(1); - } - - def = fopen(EXECLIST, "w+"); - if(def == NULL) - { - printf("open file error : %s\n", EXECLIST); - exit(1); - } - - ////// fprint table title ///// - fprintf(inf,"\n[¼oªOĵ§i]§Y¤é°_¤@­Ó¤ë¤º­Y¬ÝªO" - "¨Ï¥Î²v¤´µM¹L§C¡A«h¤©¥H¼o°£¡C\n\n" - "­^¤åªO¦W Ãþ§O ¤¤¤åªO¦W ¤é´Á " - " ªO¥D¦W³æ\n\n"); - - fprintf(def,"\n[¼oªO¤½§i]¤U¦C¬ÝªO¦]¨Ï¥Î²v¤´µM¹L§C¡A¬G¤©¥H¼o°£¡C\n\n" - "­^¤åªO¦W Ãþ§O ¤¤¤åªO¦W ¤é´Á " - " ªO¥D¦W³æ\n\n"); - - ////// start process ///// - j = 0 ; - for (i = 0; i < numboards; i++) { - rd = 0; - if(allbrd[i].brdname[0] == '\0') continue; - if((allbrd[i].brdattr & BRD_NOZAP) || - (allbrd[i].brdattr & BRD_GROUPBOARD) || - (allbrd[i].brdattr & BRD_WARNDEL) || - (allbrd[i].brdattr & BRD_HIDE) || - (allbrd[i].brdattr & BRD_POSTMASK) || - (allbrd[i].brdattr & BRD_VOTEBOARD) || - (allbrd[i].brdattr & BRD_BAD) || - (allbrd[i].level != 0)) continue; - - sprintf(fname, BBSHOME "/boards/%c/%s/.DIR", allbrd[i].brdname[0], allbrd[i].brdname); - - /* get date to choose junk board */ - /* exception when ood == 2 */ - flag = 30; - rd = get_num_records(fname, sizeof(fileheader_t)); - if(rd <= 30) - { - get_record(fname, &hdr, sizeof (hdr), 1); - strcpy(hdrdatetemp, hdr.date); - ood = outofdate(hdrdatetemp,thedate, &zapflag); - } - else - { - do{ - if(rd == 0) - { - ood = 0; - break; - } - get_record(fname, &hdr, sizeof (hdr), rd - flag); - strcpy(hdrdatetemp, hdr.date); - ood = outofdate(hdrdatetemp,thedate, &zapflag); - flag += 5; - }while(ood == 2 && flag < 60); - } - if(ood == 0) continue; - - warncount++; - /* print to file */ - fprintf(inf,"%-*.*s%-*.*s %-*.*s%-*.*s\n", IDLEN, IDLEN, - allbrd[i].brdname, BTLEN-26, BTLEN-26, allbrd[i].title, - IDLEN - 5, IDLEN-5,hdr.date, IDLEN * 3, IDLEN * 3, allbrd[i].BM); - - /* post warn file to each board */ - sprintf(genbuf,"~/bin/post %s [¼oªOĵ§i³qª¾]" - " [PTTĵ¹î§½] %s",allbrd[i].brdname,WARNFILE); - system(genbuf); - - /* 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)) - { - mailtouser(bmsname[k],allbrd[i].title, zapflag); - } - k++; - } while((p=strtok(NULL,"/ "))!=NULL); - } - /* set attribute of DeleteBoardWarn Flag */ - bcache[i].brdattr = allbrd[i].brdattr | BRD_WARNDEL; - - /* zap boards */ - if (zapflag == 1) - { - execcount++; - /* print to file */ - fprintf(def,"%-*.*s%-*.*s %-*.*s%-*.*s\n", IDLEN, IDLEN, - allbrd[i].brdname, BTLEN-26, BTLEN-26, allbrd[i].title, - IDLEN - 5, IDLEN-5,hdr.date, IDLEN * 3, IDLEN * 3, allbrd[i].BM); - - /* if you want to unmark these code, - make sure board, man path have changed to [man/]boards//brdname - */ - -// strcpy(bname, allbrd[i].brdname); -// sprintf(genbuf, -// "/bin/tar zcvf ~/tmp/board_%s.tgz boards/%s man/%s>/dev/null 2>&1;" -// "/bin/rm -fr ~/boards/%s man/%s",bname, bname, bname, bname,bname); -// system(genbuf); - -// memset(&allbrd[i], 0, sizeof(allbrd[i])); -// sprintf(allbrd[i].title, "[%s] deleted by System", bname); -// substitute_record(fn_board, &bh, sizeof(allbrd[i]), bid); -// reset_board(bid); - } - - } - - /* post to Record, ViolateLaw */ - if(warncount > 0){ - sprintf(genbuf,"~/bin/post Record [¼oªOĵ§i³qª¾]" - " [PTTĵ¹î§½] %s",WARNLIST); - system(genbuf); - sprintf(genbuf,"~/bin/post ViolateLaw [¼oªOĵ§i³qª¾]" - " [PTTĵ¹î§½] %s",WARNLIST); - system(genbuf); - } - if(execcount > 0){ - sprintf(genbuf,"~/bin/post Record [¼oªO¤½§i]" - " [PTTĵ¹î§½] %s",EXECLIST); - system(genbuf); - sprintf(genbuf,"~/bin/post ViolateLaw [¼oªO¤½§i]" - " [PTTĵ¹î§½] %s",EXECLIST); - system(genbuf); - } - - -/* Below is for test only */ -/* - mailtouser("Smile","test", 1); - mailtouser("Smile","test", 0); - - strcpy(bname, "Test"); - sprintf(genbuf,"~/bin/post %s test Smile ~/etc/test.fileaaa",bname); - system(genbuf); - - - bid = getbnum(bname); - strcpy(bname,"jourslamdunk"); - sprintf(genbuf, - "/bin/tar zcvf ~/tmp/board_%s.tgz boards/%c/%s man/%c/%s>/dev/null 2>&1;" - "/bin/rm -fr ~/boards/%c/%s man/%c/%s", - bname, bname[0], bname, bname[0], bname, bname[0], bname, bname[0], bname); - system(genbuf); - - memset(&bh, 0, sizeof(bh)); - sprintf(bh.title, "[%s] deleted by %s", bname,cuser.userid); - substitute_record(fn_board, &bh, sizeof(bh), bid); - reset_board(bid); -*/ - return 0; -} diff --git a/util/smtest.c.save b/util/smtest.c.save deleted file mode 100644 index 7e678881..00000000 --- a/util/smtest.c.save +++ /dev/null @@ -1,172 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#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 main() -{ - int bmid, i, j, k, rd; - char *p, *bmsname[3], bmbuf[IDLEN * 3 + 3], fname[256]; - fileheader_t hdr; - FILE *inf; - - 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,"­^¤åª©¦W Ãþ§O ¤¤¤åª©¦W ª©¥D¦W³æ" - " ¤é´Á ³Æµù \n"); - - j = 0 ; - for (i = 0; i < 30; i++) { - rd = 0; - if(allbrd[i].brdname[0] == '\0') continue; - - sprintf(fname, BBSHOME "/boards/%s/.DIR",allbrd[i].brdname); - - rd = get_num_records(fname, sizeof(fileheader_t)); - get_record(fname, &hdr, sizeof (hdr), rd - 30); -// printf(" %s %s\n",hdr.title,hdr.date); - - printf("%-*.*s%-*s%s", IDLEN, IDLEN, allbrd[i].brdname, BTLEN, - allbrd[i].title,allbrd[i].BM); - - p=strtok(allbrd[i].BM,"/ "); - if(p){ - int 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 60){ - fprintf(firef, "%-*.*s%-*.*s%-*.*s%3d¤Ñ¨S¤W¯¸\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¤Ñ¨S¤W¯¸\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 -#include -#include -#include -#include -#include -#include -#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,"­^¤åª©¦W Ãþ§O ¤¤¤åª©¦W ª©¥D¦W³æ" - " ¤é´Á ³Æµù \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 60){ - fprintf(firef, "%-*.*s%-*.*s%-*.*s%3d¤Ñ¨S¤W¯¸\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¤Ñ¨S¤W¯¸\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