void xml_chapterlinks(int current) /* set links to next/prev chap */ { /* and table of contents */ char const *documentbase; if ( !(global.d_doctype & (BOOK | REPORT)) || !current ) return; /* links only in books, reports, */ /* and outside of toc itself */ file_append(global.d_out, hashmap_textOf(&global.d_symbol, "XXxhtmlEnd")); file_append(global.d_out, hashmap_textOf(&global.d_symbol, "XXxhtmlBegin")); fputs("<table><tbody>\n", global.d_out); documentbase = hashmap_textOf(&global.d_symbol, "XXdocumentbase"); fprintf ( global.d_out, " <tr><td> <a href=\"%s%s\">%s</a></td></tr>\n", documentbase, global.d_noext, hashmap_textOf(&global.d_symbol, "tocheader") ); if (current > 1) fprintf ( global.d_out, " <tr><td> <a href=\"%s%s%02d\">%s</a></td></tr>\n", documentbase, global.d_noext, current - 1, hashmap_textOf(&global.d_symbol, "previous") ); if ((size_t)current < global.d_filecount) fprintf ( global.d_out, " <tr><td><a href=\"%s%s%02d\">%s</a></td></tr>\n", documentbase, global.d_noext, current + 1, hashmap_textOf(&global.d_symbol, "next") ); fputs("</tbody></table>\n", global.d_out); file_append(global.d_out, hashmap_textOf(&global.d_symbol, "XXxhtmlEnd")); file_append(global.d_out, hashmap_textOf(&global.d_symbol, "XXxhtmlBegin")); }
void log_attempt(const char *name, const char *addr, const char *type) { char file[STRLEN], buf[256]; snprintf(buf, sizeof(buf), "%-12.12s %-30s %s %s\n", name, format_time(fb_time(), TIME_FORMAT_ZH), addr, type); file_append(BADLOGINFILE, buf); sethomefile(file, name, BADLOGINFILE); file_append(file, buf); }
int fi_convert_svg2jpg(char *buf, int *size) { int len = *size; if (strncasecmp(buf, "<?xml", 5) != 0) return 0; unlink(FI_TMP_IMAGE_OLD); unlink(FI_TMP_IMAGE_NEW); file_append(FI_TMP_IMAGE_OLD, buf, len); system(FI_CONVERT_1); int new_size = (int)file_size(FI_TMP_IMAGE_NEW); if (new_size > 512*1024) { rename(FI_TMP_IMAGE_NEW, FI_TMP_IMAGE_TMP); system(FI_CONVERT_2); } int fd = open(FI_TMP_IMAGE_NEW, O_RDONLY); if (fd == -1) return -1; new_size = (int)file_size(fd); read(fd, buf, new_size); close(fd); *size = new_size; return 0; }
object_t primitive_file_append(object_t argl) { char *string = obj_get_string(car(argl)); char *filename = obj_get_string(car(cdr(argl))); if(file_append(string, filename)) return obj_new_symbol("#t"); else return obj_new_symbol("#f"); }
void check_reg_extra() { struct schoolmate_info schmate; struct userec *urec = ¤tuser; char buf[192], bufe[192]; sethomefile(buf, currentuser.userid, ".regextra"); if (!dashf(buf)) { do { memset(&schmate, 0, sizeof(schmate)); strlcpy(schmate.userid, currentuser.userid, sizeof(schmate.userid)); screen_move(1, 0); //% prints("请输入个人信息. 如果输入错误,可以重新输入.\n"); prints("\xc7\xeb\xca\xe4\xc8\xeb\xb8\xf6\xc8\xcb\xd0\xc5\xcf\xa2. \xc8\xe7\xb9\xfb\xca\xe4\xc8\xeb\xb4\xed\xce\xf3,\xbf\xc9\xd2\xd4\xd6\xd8\xd0\xc2\xca\xe4\xc8\xeb.\n"); /*default value is 0*/ do { //% getdata(2, 0, "输入以前的学号: ", schmate.school_num, getdata(2, 0, "\xca\xe4\xc8\xeb\xd2\xd4\xc7\xb0\xb5\xc4\xd1\xa7\xba\xc5: ", schmate.school_num, sizeof(schmate.school_num), DOECHO, YEA); } while (!isNumStr(schmate.school_num)); //如果有输入非数字,重新输入!下同 do { //% getdata(4, 0, "输入邮箱(外部邮箱亦可): ", schmate.email, STRLEN, getdata(4, 0, "\xca\xe4\xc8\xeb\xd3\xca\xcf\xe4(\xcd\xe2\xb2\xbf\xd3\xca\xcf\xe4\xd2\xe0\xbf\xc9): ", schmate.email, sizeof(schmate.email), DOECHO, YEA); } while (!valid_addr(schmate.email)); do { //% getdata(6, 0, "输入身份证号码: ", schmate.identity_card_num, getdata(6, 0, "\xca\xe4\xc8\xeb\xc9\xed\xb7\xdd\xd6\xa4\xba\xc5\xc2\xeb: ", schmate.identity_card_num, sizeof(schmate.identity_card_num), DOECHO, YEA); } while (!isNumStrPlusX(schmate.identity_card_num) || strlen(schmate.identity_card_num) !=IDCARDLEN); do { //% getdata(8, 0, "输入毕业证书编号: ", schmate.diploma_num, getdata(8, 0, "\xca\xe4\xc8\xeb\xb1\xcf\xd2\xb5\xd6\xa4\xca\xe9\xb1\xe0\xba\xc5: ", schmate.diploma_num, sizeof(schmate.diploma_num), DOECHO, YEA); } while (!isNumStr(schmate.diploma_num)); do { //% getdata(10, 0, "输入手机或固定电话号码: ", schmate.mobile_num, getdata(10, 0, "\xca\xe4\xc8\xeb\xca\xd6\xbb\xfa\xbb\xf2\xb9\xcc\xb6\xa8\xb5\xe7\xbb\xb0\xba\xc5\xc2\xeb: ", schmate.mobile_num, sizeof(schmate.mobile_num), DOECHO, YEA); } while (!isNumStr(schmate.mobile_num)); strcpy(buf, ""); //% getdata(11, 0, "以上信息输入正确并进行邮箱绑定认证[Y/n]", buf, 2, DOECHO, YEA); getdata(11, 0, "\xd2\xd4\xc9\xcf\xd0\xc5\xcf\xa2\xca\xe4\xc8\xeb\xd5\xfd\xc8\xb7\xb2\xa2\xbd\xf8\xd0\xd0\xd3\xca\xcf\xe4\xb0\xf3\xb6\xa8\xc8\xcf\xd6\xa4[Y/n]", buf, 2, DOECHO, YEA); } while (buf[0] =='n' || buf[0] == 'N'); sprintf(buf, "%s, %s, %s, %s, %s\n", schmate.school_num, schmate.email, schmate.identity_card_num, schmate.diploma_num, schmate.mobile_num); sethomefile(bufe, currentuser.userid, ".regextra"); file_append(bufe, buf); do_report(".SCHOOLMATE", buf); register_send_email(urec, schmate.email); } screen_clear(); tui_check_reg_mail(); }
void check_reg_extra() { struct schoolmate_info schmate; struct userec *urec = ¤tuser; char buf[192], bufe[192]; sethomefile(buf, currentuser.userid, ".regextra"); if (!dashf(buf)) { do { memset(&schmate, 0, sizeof(schmate)); strcpy(schmate.userid, currentuser.userid); move(1, 0); prints("�����������Ϣ. ����������,������������.\n"); /*default value is 0*/ do { getdata(2, 0, "������ǰ��ѧ��: ", schmate.school_num, SCHOOLNUMLEN+1, DOECHO, YEA); } while (!isNumStr(schmate.school_num)); //��������������,��������!��ͬ do { getdata(4, 0, "��������(�ⲿ�������): ", schmate.email, STRLEN, DOECHO, YEA); } while (invalidaddr(schmate.email)); do { getdata(6, 0, "�������֤����: ", schmate.identity_card_num, IDCARDLEN+1, DOECHO, YEA); } while (!isNumStrPlusX(schmate.identity_card_num) || strlen(schmate.identity_card_num) !=IDCARDLEN); do { getdata(8, 0, "�����ҵ֤����: ", schmate.diploma_num, DIPLOMANUMLEN+1, DOECHO, YEA); } while (!isNumStr(schmate.diploma_num)); do { getdata(10, 0, "�����ֻ���̶��绰����: ", schmate.mobile_num, MOBILENUMLEN+1, DOECHO, YEA); } while (!isNumStr(schmate.mobile_num)); strcpy(buf, ""); getdata(11, 0, "������Ϣ������ȷ�������������֤[Y/n]", buf, 2, DOECHO, YEA); } while (buf[0] =='n' || buf[0] == 'N'); sprintf(buf, "%s, %s, %s, %s, %s\n", schmate.school_num, schmate.email, schmate.identity_card_num, schmate.diploma_num, schmate.mobile_num); sethomefile(bufe, currentuser.userid, ".regextra"); file_append(bufe, buf); do_report(".SCHOOLMATE", buf); regmail_send(urec, schmate.email); } clear(); check_reg_mail(); }
//#ifdef MAILCHECK //#ifdef CODE_VALID char *genrandpwd(int seed) { char panel[]= "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; char *result; int i, rnd; result = (char *) malloc(RNDPASSLEN + 1); srand((unsigned) (time(0) * seed)); memset(result, 0, RNDPASSLEN + 1); for (i = 0; i < RNDPASSLEN; i++) { rnd = rand() % sizeof(panel); if (panel[rnd] == '\0') { i--; continue; } result[i] = panel[rnd]; } sethomefile(genbuf, currentuser.userid, ".regpass"); unlink(genbuf); file_append(genbuf, result); return ((char *) result); }
int file_push_cp(const char* src, const char* dst) { return file_append("F\n%s\n%s\n", src, dst); }
int file_push_mkdir(const char* dir) { return file_append("D\n%s\n", dir); }
int bbslogin_main(void) { char fname[STRLEN]; char buf[256], id[IDLEN + 1], pw[PASSLEN]; struct userec user; if (parse_post_data() < 0) return BBS_EINVAL; strlcpy(id, getparm("id"), sizeof(id)); if (*id == '\0') return login_screen(); strlcpy(pw, getparm("pw"), sizeof(pw)); if (loginok && !strcasecmp(id, currentuser.userid)) { const char *ref = get_login_referer(); printf("Location: %s\n\n", ref); return 0; } if (getuserec(id, &user) == 0) return BBS_ENOUSR; user.numlogins++; if (strcasecmp(id, "guest")) { int total; time_t stay, recent, now, t; if (!checkpasswd(user.passwd, pw)) { sprintf(buf, "%-12.12s %s @%s\n", user.userid, getdatestring(time(NULL), DATE_ZH), fromhost); sethomefile(fname, user.userid, "logins.bad"); file_append(fname, buf); file_append("logins.bad", buf); return BBS_EWPSWD; } total = check_multi(&user); if (!HAS_PERM2(PERM_SYSOPS, &user) && total >= 2) return BBS_ELGNQE; if (!HAS_PERM2(PERM_LOGIN, &user)) return BBS_EACCES; now = time(NULL); // Do not count frequent logins. if (now - user.lastlogin < 20 * 60 && user.numlogins >= 100) user.numlogins--; if (total > 1) { recent = user.lastlogout; if (user.lastlogin > recent) recent = user.lastlogin; stay = now - recent; if (stay < 0) stay = 0; } else { stay = 0; } t = user.lastlogin; user.lastlogin = now; user.stay += stay; #ifdef CHECK_FREQUENTLOGIN if (!HAS_PERM(PERM_SYSOPS) && abs(t - time(NULL)) < 10) { report("Too Frequent", user.userid); return BBS_ELFREQ; } #endif strlcpy(user.lasthost, fromhost, sizeof(user.lasthost)); save_user_data(&user); currentuser = user; } log_usies("ENTER", fromhost, &user); if (!loginok && strcasecmp(id, "guest")) wwwlogin(&user, getparm("ref")); return 0; }
int main(int argc, char **argv) { u8 r; char filename[255] = "misc/hosts_temp"; struct addr address; if (argc > 1) { if (strcmp("append", argv[1]) == 0 || strcmp("search", argv[1]) == 0) { if (argc < 3) { printf("Unknown address\n"); return 1; } r = sscanf(argv[2], "%hhu.%hhu.%hhu.%hhu", &address.chunk.a, &address.chunk.b, &address.chunk.c, &address.chunk.d); if (r != 4) { printf("Ivalid address %u.%u.%u.%u\n", (u32) address.chunk.a, (u32) address.chunk.b, (u32) address.chunk.c, (u32) address.chunk.d); return 1; } r = file_search(filename, address); if (strcmp("append", argv[1]) == 0) { if (r == 1) { printf("Address %u.%u.%u.%u exists\n", address.chunk.a, address.chunk.b, address.chunk.c, address.chunk.d); // return 1; } r = file_append(filename, address); printf("%s address %u.%u.%u.%u!\n", r == 0 ? "Not added" : "Added", address.chunk.a, address.chunk.b, address.chunk.c, address.chunk.d); } else { printf("%s address %u.%u.%u.%u!\n", r == 0 ? "Not found" : "Found", address.chunk.a, address.chunk.b, address.chunk.c, address.chunk.d); } } else if (strcmp("print", argv[1]) == 0) { u32 i; struct peers *tmp = file_fetch(filename); for (i = 0; i < tmp->cnt; ++i) printf("%u.%u.%u.%u\n", tmp->itms[i].chunk.a, tmp->itms[i].chunk.b, tmp->itms[i].chunk.c, tmp->itms[i].chunk.d); printf("Found %u hosts\n", tmp->cnt); free(tmp); } else if (strcmp("clean", argv[1]) == 0) { file_clean(filename); printf("Cleaned\n"); } else printf("Unknown command\n"); } return 0; }
void touchnew() { sprintf(genbuf, "touch by: %d\n", time(0)); file_append(FLUSH, genbuf); }