int main() { int i; struct boardmem x; if (initbbsinfo(&bbsinfo) < 0) return -1; shm_bcache = bbsinfo.bcacheshm; if (shm_bcache->number <= 0) return -1; initfilter(MY_BBS_HOME "/etc/filtertitle"); srand(time(NULL)); for (i = 0; i < shm_bcache->number; i++) { x = shm_bcache->bcache[i]; if (!testperm(&x)) continue; bzero(&lastmarklist[numlastmarkb], sizeof (lastmarklist[0])); strcpy(lastmarklist[numlastmarkb].board, x.header.filename); strcpy(lastmarklist[numlastmarkb].boardtitle, x.header.title); lastmarklist[numlastmarkb].bnum = i; lastmarklist[numlastmarkb].score = x.score; strsncpy(lastmarklist[numlastmarkb].sec1, x.header.sec1, sizeof (lastmarklist[numlastmarkb].sec1)); strsncpy(lastmarklist[numlastmarkb].sec2, x.header.sec2, sizeof (lastmarklist[numlastmarkb].sec2)); if (!(x.header.flag & CLOSECLUB_FLAG)) readlastmark(&lastmarklist[numlastmarkb]); numlastmarkb++; } makeallseclastmark(§ree); return 0; }
//argv[1]: -1: 清理所有封禁/警告标记; 0: 只进行解封; //1: 解封和警告; 2: 封禁/解封和警告 int main(int argn, char **argv) { int i; int oldvalue; struct boardheader *bh; char *(valuestr[]) = { "解封", "警告", "封禁" }; printf("自动封禁/解封版面\n运行时间: %s\n", Ctime(time(NULL))); if (argn >= 2) level = atoi(argv[1]); if (level > 2 || level < -1) level = 0; if (initbbsinfo(&bbsinfo) < 0) { printf("Failed to attach shm.\n"); return -1; } if (uhash_uptime() == 0) { printf("Failed to access uhash.\n"); return -1; } chdir(MY_BBS_HOME); for (i = 0; i < MAXBOARD; i++) { bh = &bbsinfo.bcache[i].header; if (!bh->filename[0]) continue; if (!strcasecmp(bh->filename, "syssecurity")) { bbsinfo.bcache[i].ban = 0; continue; } if (level == -1) { bbsinfo.bcache[i].ban = 0; continue; } oldvalue = bbsinfo.bcache[i].ban; bbsinfo.bcache[i].ban = shouldBan(bh, bbsinfo.bcache[i].ban); if (bbsinfo.bcache[i].ban || oldvalue) printf("%-20.20s %s ==> %s\n", bh->filename, valuestr[oldvalue], valuestr[(int) bbsinfo.bcache[i].ban]); } genfiles(); return 0; }
int main(void) { int i; if (initbbsinfo(&bbsinfo) < 0) goto quit; if (load_ucache() < 0) goto quit; for (i = 0; i < 4; i++) { getrandomint(&(bbsinfo.ucachehashshm->regkey[i])); getrandomint(&(bbsinfo.ucachehashshm->oldregkey[i])); } bbsinfo.ucachehashshm->keytime = time(NULL); bbsinfo.ucachehashshm->uptime = time(NULL); return 0; quit: printf("E!\n"); return -1; }
int main() { gdImagePtr im; int black; int white; int brect[8]; int x, y; char *err; char s[5]; /* String to draw. */ double sz = 40.; char fontpath[256]; unsigned int r; char buf[50]; char userid[IDLEN + 1]; struct MD5Context mdc; unsigned int pass[4]; if (initbbsinfo(&bbsinfo) < 0) return -1; bzero(pass, sizeof(pass)); strsncpy(buf, getsenv("QUERY_STRING"), sizeof (buf)); __unhcode(buf); if (strncmp(buf, "userid=", 7)) { userid[0] = 0; } else { strsncpy(userid, buf+7, IDLEN+1); // errlog("%s",userid); } if (userid[0] == 0) { s[0] = 0; } else { MD5Init(&mdc); MD5Update(&mdc, (void *)(&bbsinfo.ucachehashshm->regkey), sizeof(int) * 4); MD5Update(&mdc, userid, strlen(userid)); MD5Final((char *)pass, &mdc); sprintf(s, "%d%d%d%d", pass[0]%10, pass[1] % 10, pass[2] % 10, pass[3] % 10); } getrandomint(&r); sprintf(fontpath, MY_BBS_HOME "/etc/fonts/%d.ttf", r % MAXFONTS); /* User supplied font */ fprintf(stdout, "Content-type: image/png\r\n\r\n"); /* obtain brect so that we can size the image */ err = gdImageStringTTF(NULL, &brect[0], 0, fontpath, sz, 0., 0, 0, s); if (err) { return 1; } /* create an image big enough for the string plus a little whitespace */ x = brect[2] - brect[6] + 6; y = brect[3] - brect[7] + 6; im = gdImageCreate(x, y); /* Background color (first allocated) */ white = gdImageColorResolve(im, 255, 255, 255); black = gdImageColorResolve(im, 0, 0, 0); /* render the string, offset origin to center string*/ /* note that we use top-left coordinate for adjustment * since gd origin is in top-left with y increasing downwards. */ x = 3 - brect[6]; y = 3 - brect[7]; err = gdImageStringFT(im, &brect[0], black, fontpath, sz, 0.0, x, y, s); if (err) { return 1; } /* Write img to stdout */ gdImagePng(im, stdout); /* Destroy it */ gdImageDestroy(im); return 0; }