コード例 #1
0
ファイル: mbbsd.c プロジェクト: YanlongLai/Program
static void start_client() {
    extern struct commands_t cmdlist[];
    int nreg;
    
    /* system init */
    currmode = 0;
    
    signal(SIGHUP, abort_bbs);
    signal(SIGTERM, abort_bbs);
    signal(SIGPIPE, abort_bbs);

    signal(SIGINT, abort_bbs_debug);
    signal(SIGQUIT, abort_bbs_debug);
    signal(SIGILL, abort_bbs_debug);
    signal(SIGABRT, abort_bbs_debug);
    signal(SIGFPE, abort_bbs_debug);
    signal(SIGBUS, abort_bbs_debug);
    signal(SIGSEGV, abort_bbs_debug);
    
    signal_restart(SIGUSR1, talk_request);
    signal_restart(SIGUSR2, write_request);
    
    dup2(0, 1);
    
    do_term_init();
    signal(SIGALRM, abort_bbs);
    alarm(600);
    login_query();		/* Ptt 加上login time out */
    user_login();
    m_init();

#if FORCE_PROCESS_REGISTER_FORM    
    if (HAS_PERM(PERM_SYSOP) && (nreg = dashs(fn_register)/163) > 100)
    {
    	char cpu_load[30];
    	if(cpuload(cpu_load) > MAX_CPULOAD*2/3)	/* DickG: 根據目前的 load 來 */
	    scan_register_form(fn_register, 1, nreg/20); /* 決定要審核的數目 */
	else
	    scan_register_form(fn_register, 1, nreg/10);
    }
#endif
    if(HAVE_PERM(PERM_SYSOP | PERM_BM))
	b_closepolls();
    if(!(cuser.uflag & COLOR_FLAG))
	showansi = 0;
#ifdef DOTIMEOUT
    /* init_alarm();*/ // cause strange logout with saving post.
    signal(SIGALRM, SIG_IGN);
#else
    signal(SIGALRM, SIG_IGN);
#endif
    if(chkmailbox())
	m_read();
    
    domenu(MMENU, "主功\能表", (chkmail(0) ? 'M' : 'C'), cmdlist);
}
コード例 #2
0
ファイル: indict.c プロジェクト: YanlongLai/Program
static void addword(char word[]) {
    char buf[150],temp[150],a[3];
    FILE *fp = fopen(database,"r+");

    fgets(buf,130,fp);
    fseek(fp,0,2);
    if(HAVE_PERM(PERM_LOGINOK)) {
	clear();
	move(4,0);
	outs(" \033[31m警告\033[m:若蓄意填寫假資料將\033[36m砍id\033[m處份\n");
	sprintf(temp, "\n輸入範利\n:\033[33m%s\033[m", buf);
	outs(temp);
	outs("\n請依上列範例輸入一行資料(直接enter放棄)\n");
	getdata(10, 0, ":", buf, 65, DOECHO);
	if(buf[0]) {
	    getdata(13, 0, "確定新增?(Y/n)", a, 2, LCECHO);
	    if(a[0] != 'n')
		fprintf(fp, "%-65s[%s]\n", buf, cuser.userid);
	}
    }
    fclose(fp);
    clear();
}
コード例 #3
0
ファイル: xyz.c プロジェクト: dk00/old-stuff
int
Goodbye()
{
  extern void movie();
  char genbuf[200];

/*
woju
*/
  char ans[4];


  setuserfile(genbuf, fn_writelog);
  if (more(genbuf, NA) != -1) {
/* MH */
/* Àˬd¤ô²y°O¿ý®e¶q, ÁקK¦³¤H¡u¤Ù¿n¡v¤j¶q¤ô²y */
     struct stat st;
     int writelog_limit;
    
     if (HAS_PERM(PERM_BM))
        writelog_limit = MH_WRITELOGLIMIT_BM;
     else if (HAS_PERM(PERM_LOGINOK))
        writelog_limit = MH_WRITELOGLIMIT_LOGINOK;
     else
        writelog_limit = MH_WRITELOGLIMIT_BASIC;
     do
     {
       char buf[80];
       
       setuserfile(buf, fn_writelog);
       stat(buf, &st);
       if(!HAVE_PERM(PERM_SYSOP) && !HAVE_PERM(PERM_MAILLIMIT) && st.st_size / 1024 > writelog_limit)
       {
         my_outmsg_row("±zªº¤ô²y°O¿ý¤w¶W¹L­­©w®e¶q¡AµLªk¿ï¾Ü¡u«O¯d¡v", b_lines - 2);
         getdata(b_lines - 1, 0, "²M°£(C) ²¾¦Ü³Æ§Ñ¿ý(M) (C/M)?[M]",
            ans, 3, LCECHO, 0);
       }
       else
       {
         getdata(b_lines - 1, 0, "²M°£(C) ²¾¦Ü³Æ§Ñ¿ý(M) «O¯d(R) (C/M/R)?[R]",
            ans, 3, LCECHO, 0);
       }
       if (*ans == 'm') {
          fileheader mymail;
          char title[128], buf[80];

          sethomepath(buf, cuser.userid);
          stampfile(buf, &mymail);

          mymail.savemode = 'H';        /* hold-mail flag */
          mymail.filemode = FILE_READ;
          strcpy(mymail.owner, "[³Æ.§Ñ.¿ý]");
          strcpy(mymail.title, "¼ö½u°O¿ý");
          if(mh_memoforward(cuser.userid, genbuf, &mymail, sizeof(mymail)))
          {
            sethomedir(title, cuser.userid);
            append_record(title, &mymail, sizeof(mymail));
            /* MH: ³Æ§Ñ¿ý¥[¤W§@ªÌ¼ÐÃDµ¥¸ê°T...¤£µM¦b'x'Âà±H©Î¬Obuildirªº®É­Ô
                   ·|Äê±¼ */
#if 1
            {
              FILE *src, *dst;
              char buf2[200];
              time_t now;
              
              if((src = fopen(genbuf, "r")) == NULL)
              {
                sprintf(buf2, "errno: %d, genbuf:%s", errno, genbuf);
                log_usies("MH ", buf2);
              }
              if((dst = fopen(buf, "w")) == NULL)
              {
                sprintf(buf2, "errno: %d, buf:%s", errno, buf);
                log_usies("MH ", buf2);
                fclose(src);
              }
              now = time(NULL);
              sprintf(buf2, "§@ªÌ: %s\n¼ÐÃD: %s\n®É¶¡: %s\n", mymail.owner, mymail.title, ctime(&now));
              fputs(buf2, dst);
              while(fgets(buf2, 199, src) != NULL)
                fputs(buf2, dst);
              fclose(src);
              fclose(dst);
              unlink(genbuf);
            }
#else
            Rename(genbuf, buf);
#endif
          }
        }
       else if (*ans == 'c') {
          char buf[80];

          setuserfile(buf, fn_writelog);
          unlink(buf);
       }
     } while(!HAVE_PERM(PERM_SYSOP) && !HAVE_PERM(PERM_MAILLIMIT) && st.st_size / 1024 > writelog_limit && *ans != 'm' && *ans != 'c');

      clear();
      move(0, 0);
      prints("                             °ª¶¯¤¤¾Ç-¬õ¼Ó¿v¹Ú                                ");
      movie(0);
  }
/*    */

  getdata(b_lines - 1, 0, "±z½T©w­nÂ÷¶}¡i " BOARDNAME " ¡j¶Ü(Y/N)¡H[N] ",
    genbuf, 3, LCECHO, 0);

  if (*genbuf != 'y')
    return 0;

  movie(999);
  if (cuser.userlevel)
  {
    getdata(b_lines - 1, 0, "(G)ÀH­·¦Ó³u (M)¦«¹Ú¯¸ªø (N)¦X§@ªÀªº¨¥½×¼s³õ¡H[G] ",
      genbuf, 3, LCECHO, 0);
    if (genbuf[0] == 'm')
      mail_sysop();
    else if (genbuf[0] == 'n')
      note();
  }

  save_userrc();
#if 0
  save_mailmsg();
#endif

  clear();
  prints("¿Ë·Rªº %s(%s)¡A§O§Ñ¤F¦A«×¥úÁ{"
    " %s ¡I\n¥H¤U¬O±z¦b¯¸¤ºªºµù¥U¸ê®Æ:\n",
    cuser.userid, cuser.username, BoardName);
  user_display(&cuser, 0);

  if (currmode)
    u_exit("EXIT ");

  pressanykey();
  sleep(1);
  reset_tty();
  exit(0);
}