Example #1
0
static void do_talk(int fd)
{
   struct talk_win mywin, itswin;
   time_t talkstart;
   usint myword = 0,itword = 0;
   char mid_line[128], data[200];
   int i, ch, datac;
   int im_leaving = 0;
   struct tm *ptime;
   time_t now;
   char genbuf[200], fpath[100];

   time(&now);
   ptime = localtime(&now);

   sethomepath(fpath, cuser.userid);
   strcpy(fpath, tempnam(fpath, "talk_"));
   flog = fopen(fpath, "w");

   setutmpmode(TALK);

   ch = 58 - strlen(save_page_requestor);
   sprintf(genbuf, "%s【%s", cuser.userid, cuser.username);
   i = ch - strlen(genbuf);
   if (i >= 0)
      i = (i >> 1) + 1;
   else
   {
Example #2
0
File: miscd.c Project: wyat/kbs
int killauser(struct userec *theuser, void *data)
{
    int a;
    struct userec *ft,copyuser;

    if (!theuser || theuser->userid[0] == 0)
        return 0;
    memcpy(&copyuser,theuser,sizeof(copyuser));

    if (id_invalid(copyuser.userid))
        return 0;

    a = compute_user_value(&copyuser);

    if ((a <= 0)&&strcmp(copyuser.userid,"guest")) {
        newbbslog(BBSLOG_USIES, "kill user %s", copyuser.userid);
        kick_user_utmp(getuser(copyuser.userid, NULL), NULL, SIGKILL);
        a = getuser(copyuser.userid, &ft);
        setmailpath(tmpbuf, copyuser.userid);
        sprintf(genbuf1, "/bin/rm -rf %s", tmpbuf);
        system(genbuf1);
        sethomepath(tmpbuf, copyuser.userid);
        sprintf(genbuf1, "/bin/rm -rf %s", tmpbuf);
        system(genbuf1);
        sprintf(genbuf1, "/bin/rm -fr tmp/email/%s", copyuser.userid);
        system(genbuf1);
        setuserid2(a, "");
        theuser->userlevel = 0;
        /*strcpy(theuser->address, "");*/
        strcpy(theuser->username, "");
        /*strcpy(theuser->realname, "");*/
    }

    return 0;
}
Example #3
0
static int retrieve_backup(userec_t *user)
{
    int     uid;
    char    src[PATHLEN], dst[PATHLEN];
    char    ans;

    if ((uid = searchuser(user->userid, user->userid))) {
	userec_t orig;
	passwd_sync_query(uid, &orig);
	strlcpy(user->passwd, orig.passwd, sizeof(orig.passwd));
	setumoney(uid, user->money);
	passwd_sync_update(uid, user);
	return 0;
    }

    ans = vans("目前的 PASSWD 檔沒有此 ID,新增嗎?[y/N]");

    if (ans != 'y') {
	vmsg("目前的 PASSWDS 檔沒有此 ID,請先新增此帳號");
	return -1;
    }

    if (setupnewuser((const userec_t *)user) >= 0) {
	sethomepath(dst, user->userid);
	if (!dashd(dst)) {
	    snprintf(src, sizeof(src), "tmp/%s", user->userid);
	    if (!dashd(src) || !Rename(src, dst))
		mkuserdir(user->userid);
	}
	return 0;
    }
    return -1;
}
Example #4
0
/* 创建以username为名,以passwd为密码的用户 */
void add_bbsid(char *username, char *passwd)
{
    struct userec *newuser;
    int unum;
    char path[PATHLEN];
    char buf[PATHLEN];

    unum = getnewuserid(username);
    if (unum > MAXUSERS || unum <= 0) {
        clean_ipc();
        error("%s: unum error", username);
    }
    strcpy(buf, username);
    unum = getuser(buf, &newuser);
    setpasswd(passwd, newuser);

    if (!strcmp(username, "SYSOP")) {
        newuser->flags = (char)1;
        strcpy(newuser->username, "系统管理员");
        newuser->userdefine[0] = (unsigned int)3221224447U;
        newuser->userdefine[1] = (unsigned int)4294967295U;
        newuser->userlevel = (unsigned int)0xDAFFDFFF;
    } else if (!strcmp(username, "guest")) {
        newuser->flags = (char)9;
        newuser->userlevel = (unsigned int)536879104U;
        strcpy(newuser->username, "和谐");
        newuser->userdefine[0] = (unsigned int)3221224447U;
        newuser->userdefine[1] = (unsigned int)4294967295U;
    }

    update_user(newuser, unum, 1);

    newbbslog(BBSLOG_USIES, "APPLY: %s uid %d from %s",
            newuser->userid, unum, "127.0.0.1");
    bbslog("user", "%s", "new account");
    usage("add user %s", username);

    sethomepath(path, newuser->userid);
    sprintf(buf, "/bin/mv -f %s %s/homeback/%s", path, BBSHOME, newuser->userid);
    system(buf);
    sprintf(buf, "/bin/mv -f %s %s/mailback/%s", path, BBSHOME, newuser->userid);
    system(buf);
    if (strcmp(username, "guest"))      /* 不给 guest 发信 */
        mail_file(DELIVER, "etc/tonewuser", newuser->userid, "致新注册用户的信", 0, NULL);
}
Example #5
0
static void create_userdata(olduserec * olduser)
{
    struct userdata ud;
    char datafile[256];
    int fd;
    struct stat st;

    bzero(&ud, sizeof(ud));
    memcpy(ud.userid, olduser->userid, sizeof(ud.userid));
    memcpy(ud.realemail, olduser->reginfo, sizeof(ud.realemail));
    memcpy(ud.realname, olduser->realname, sizeof(ud.realname));
    memcpy(ud.address, olduser->address, sizeof(ud.address));
    memcpy(ud.email, olduser->email, sizeof(ud.email));
#ifdef HAVE_BIRTHDAY
    ud.gender = olduser->gender;
    ud.birthyear = olduser->birthyear;
    ud.birthmonth = olduser->birthmonth;
    ud.birthday = olduser->birthday;
#endif

    sethomepath(datafile, olduser->userid);
    if (stat(datafile, &st) == -1) {
        fprintf(stderr, "Warning: %s's home directory not found.\n", olduser->userid);
        fprintf(stderr, "         Creating it.\n");
        if (mkdir(datafile, 0755) == -1)
            return;
    } else {
        if (!(st.st_mode & S_IFDIR))
            return;
    }
    sethomefile(datafile, olduser->userid, USERDATA);
    if ((fd = open(datafile, O_WRONLY | O_CREAT, 0644)) < 0) {
        fprintf(stderr, "open %s failed.\n", datafile);
        return;
    }
    if (write(fd, &ud, sizeof(ud)) < 0)
        fprintf(stderr, "write %s failed.\n", datafile);
    close(fd);
}
Example #6
0
File: xyz.c Project: 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);
}
Example #7
0
/**
 * Telnet register interface.
 */
void new_register(void)
{
	char userid[IDLEN + 1], passwd[PASSLEN], passbuf[PASSLEN], log[STRLEN];
	const char *errmsg;

	if (register_closed()) {
		ansimore("NOREGISTER", NA);
		pressreturn();
		return;
	}

	ansimore("etc/register", NA);
#ifndef FDQUAN
	//% if (!askyn("您是否同意本站Announce版精华区x-3目录所列站规?", false, false))
	if (!askyn("\xc4\xfa\xca\xc7\xb7\xf1\xcd\xac\xd2\xe2\xb1\xbe\xd5\xbe""Announce\xb0\xe6\xbe\xab\xbb\xaa\xc7\xf8x-3\xc4\xbf\xc2\xbc\xcb\xf9\xc1\xd0\xd5\xbe\xb9\xe6?", false, false))
		return;
#endif

	int tried = 0;
	prints("\n");
	while (1) {
		if (++tried >= MAX_NEW_TRIES) {
			//% outs("\n拜拜,按太多下  <Enter> 了...\n");
			outs("\n\xb0\xdd\xb0\xdd\xa3\xac\xb0\xb4\xcc\xab\xb6\xe0\xcf\xc2  <Enter> \xc1\xcb...\n");
			screen_flush();
			return;
		}

		//% getdata(0, 0, "请输入帐号名称 (Enter User ID, \"0\" to abort): ",
		getdata(0, 0, "\xc7\xeb\xca\xe4\xc8\xeb\xd5\xca\xba\xc5\xc3\xfb\xb3\xc6 (Enter User ID, \"0\" to abort): ",
				userid, sizeof(userid), DOECHO, YEA);
		if (userid[0] == '0')
			return;
		errmsg = register_invalid_user_name(userid);
		if (errmsg != NULL) {
			outs(errmsg);
			continue;
		}

		char path[HOMELEN];
		sethomepath(path, userid);
		if (dosearchuser(userid, &currentuser, &usernum) || dashd(path)) {
			//% outs("此帐号已经有人使用\n");
			outs("\xb4\xcb\xd5\xca\xba\xc5\xd2\xd1\xbe\xad\xd3\xd0\xc8\xcb\xca\xb9\xd3\xc3\n");
			continue;
		}
#ifndef REG_CAPTCHA
		break;
#else
		char link[STRLEN], attempt[CAPTCHA_LEN + 1], answer[CAPTCHA_LEN + 1];
		int lnum;
		int pos = gen_captcha_link(link, sizeof(link), &lnum);
		if (pos < 0)
			return;

		prints("http://"BBSHOST"/captcha/%d.gif\n", lnum);
		//% getdata(0, 0, "请输入上图所包含的英文字母: ", attempt, sizeof(attempt),
		getdata(0, 0, "\xc7\xeb\xca\xe4\xc8\xeb\xc9\xcf\xcd\xbc\xcb\xf9\xb0\xfc\xba\xac\xb5\xc4\xd3\xa2\xce\xc4\xd7\xd6\xc4\xb8: ", attempt, sizeof(attempt),
				DOECHO, YEA);
		unlink(link);

		get_captcha_answer(pos, answer, sizeof(answer));
		if (strcasecmp(answer, attempt) != 0) {
			//% outs("验证码输入错误...\n");
			outs("\xd1\xe9\xd6\xa4\xc2\xeb\xca\xe4\xc8\xeb\xb4\xed\xce\xf3...\n");
			continue;
		} else {
			break;
		}
#endif // REG_CAPTCHA
	}

	for (tried = 0; tried <= MAX_SET_PASSWD_TRIES; ++tried) {
		passbuf[0] = '\0';
		//% getdata(0, 0, "请设定您的密码 (Setup Password): ", passbuf,
		getdata(0, 0, "\xc7\xeb\xc9\xe8\xb6\xa8\xc4\xfa\xb5\xc4\xc3\xdc\xc2\xeb (Setup Password): ", passbuf,
				sizeof(passbuf), NOECHO, YEA);
		errmsg = register_invalid_password(passbuf, userid);
		if (errmsg) {
			outs(errmsg);
			continue;
		}
		strlcpy(passwd, passbuf, PASSLEN);
		//% getdata(0, 0, "请再输入一次您的密码 (Confirm Password): ", passbuf,
		getdata(0, 0, "\xc7\xeb\xd4\xd9\xca\xe4\xc8\xeb\xd2\xbb\xb4\xce\xc4\xfa\xb5\xc4\xc3\xdc\xc2\xeb (Confirm Password): ", passbuf,
				PASSLEN, NOECHO, YEA);
		if (strncmp(passbuf, passwd, PASSLEN) != 0) {
			//% prints("密码输入错误, 请重新输入密码\n");
			prints("\xc3\xdc\xc2\xeb\xca\xe4\xc8\xeb\xb4\xed\xce\xf3, \xc7\xeb\xd6\xd8\xd0\xc2\xca\xe4\xc8\xeb\xc3\xdc\xc2\xeb\n");
			continue;
		}
		passwd[8] = '\0';
		break;
	}
	if (tried > MAX_SET_PASSWD_TRIES)
		return;

	struct userec user;
	init_userec(&user, userid, passwd, true);
	strlcpy(user.lasthost, fromhost, sizeof(user.lasthost));

	if (create_user(&user) < 0) {
		outs("Failed to create user.\n");
		return;
	}

	snprintf(log, sizeof(log), "new account from %s", fromhost);
	report(log, currentuser.userid);

	//% prints("请重新登录 %s 并填写注册信息\n", user.userid);
	prints("\xc7\xeb\xd6\xd8\xd0\xc2\xb5\xc7\xc2\xbc %s \xb2\xa2\xcc\xee\xd0\xb4\xd7\xa2\xb2\xe1\xd0\xc5\xcf\xa2\n", user.userid);
	pressanykey();
	return;
}
Example #8
0
int x_love() {
    char buf1[200], save_title[TTLEN + 1];
    char receiver[61], path[STRLEN] = "home/";
    int x, y = 0, tline = 0, poem = 0;
    FILE *fp, *fpo;
    time_t timenow;
    struct tm *gtime;
    fileheader_t mhdr;
    
    setutmpmode(LOVE);
    time(&timenow);
    gtime = localtime(&timenow);
    sprintf(buf1,"%c/%s/love%d%d",
	    cuser.userid[0], cuser.userid,gtime->tm_sec,gtime->tm_min);
    strcat(path,buf1);
    move(1,0);
    clrtobot();
    
    outs("\n歡迎使用情書產生器 v0.00 版 \n");
    outs("有何難以啟齒的話,交由系統幫你說吧.\n爸爸說 : 濫情不犯法.\n");
    
    if(!getdata(7, 0, "收信人:", receiver, 60, DOECHO)) return 0;
    if(receiver[0] && !(searchuser(receiver) &&
			getdata(8, 0, "主  題:", save_title,
				TTLEN, DOECHO))) {
	move(10, 0);
	outs("收信人或主題不正確, 情書無法傳遞. ");
	pressanykey();
	return 0;
    }
    
    fpo = fopen(path, "w");
    fprintf(fpo, "\n");
    if((fp = fopen(DATA, "r"))) {
	while(fgets(buf1,100, fp)) {
	    switch(buf1[0]) {
	    case '#':
		break;
	    case '@':
		if(!strncmp(buf1, "@begin", 6) || !strncmp(buf1, "@end", 4))
		    tline=3;
		else if(!strncmp(buf1,"@poem",5)) {
		    poem = 1;
		    tline = 1;
		    fprintf(fpo, "\n\n");
		} else
		    tline=2;
		break;
	    case '1':
	    case '2':
	    case '3':
	    case '4':
	    case '5':
	    case '6':
	    case '7':
	    case '8':
	    case '9':
		sscanf(buf1,"%d",&x);
		y = (rand() % (x - 1)) * tline; 
		break;
	    default:
		if(!poem) {
		    if(y > 0)
			y = y - 1;
		    else {
			if(tline > 0) {
			    fprintf(fpo, "%s", buf1);
			    tline--;
			}
		    }
		} else {
		    if(buf1[0] == '$')
			y--;
		    else if(y == 0)
			fprintf(fpo,"%s",buf1);
		}
	    } 

	}
	
	fclose(fp);
	fclose(fpo);
	if(vedit(path, YEA, NULL) == -1) {
	    unlink(path);
	    clear();
	    outs("\n\n 放棄寄情書\n");
	    pressanykey();
	    return -2;
	}
	sethomepath(buf1, receiver);
	stampfile(buf1, &mhdr);
	Rename(path, buf1);
	strncpy(mhdr.title, save_title, TTLEN);
	strcpy(mhdr.owner, cuser.userid);
	mhdr.savemode = '\0';
	sethomedir(path, receiver );
	if(append_record(path, &mhdr, sizeof(mhdr)) == -1)
	    return -1;
	hold_mail(buf1, receiver);
	return 1;
    }
    return 0;
}
Example #9
0
File: register.c Project: wyat/kbs
void new_register()
{
    struct userec newuser;
    int allocid, do_try, flag;
    char buf[STRLEN];

    /* temp !!!!!*/

#ifdef SECONDSITE
    prints("不接受新帐号注册!!!\n");
    oflush();
    sleep(2);
    exit(-1);
#else

    /*    prints("Sorry, we don't accept newusers due to system problem, we'll fixit ASAP\n");
        oflush();
        sleep(2);
        exit(-1);
    */
    memset(&newuser, 0, sizeof(newuser));
    getdata(0, 0, "使用GB编码阅读?(\xa8\xcf\xa5\xce BIG5\xbd\x58\xbe\x5c\xc5\xaa\xbd\xd0\xbf\xefN)(Y/N)? [Y]: ", buf, 4, DOECHO, NULL, true);
    if (*buf == 'n' || *buf == 'N')
        if (!convcode)
            switch_code();

    ansimore("etc/register", false);
    do_try = 0;
    while (1) {
        if (++do_try >= 10) {
            prints("\n掰掰,按太多下  <Enter> 了...\n");
            refresh();
            longjmp(byebye, -1);
        }
        getdata(0, 0, "请输入代号: ", newuser.userid, IDLEN + 1, DOECHO, NULL, true);
        flag = 1;
        if (id_invalid(newuser.userid) == 1) {
            prints("帐号必须由英文字母或数字组成,并且第一个字符必须是英文字母!\n");
            /*                prints("帐号必须由英文字母或数字,而且帐号第一个字是英文字母!\n"); */
            flag = 0;
        }
        if (flag) {
            if (strlen(newuser.userid) < 2) {
                prints("代号至少需有两个英文字母!\n");
            } else if ((strcasecmp(newuser.userid, "SYSOP") == 0) && (strcmp(newuser.userid, "SYSOP") != 0) && searchuser("SYSOP") == 0) {
                prints("抱歉,本站只允许注册*全部*大写的SYSOP用户ID。\n");
            } else if (!strcasecmp(newuser.userid, "guest") && strcmp(newuser.userid, "guest") && !searchuser("guest")) {
                prints("抱歉,本站只允许注册*全部*小写的guest用户ID。\n");
            } else if ((*newuser.userid == '\0') || bad_user_id(newuser.userid) || (strcasecmp(newuser.userid, "SYSOPS") == 0) || (strcasecmp(newuser.userid, "BMS") == 0)) {
                prints("抱歉,本站暂不提供此帐号注册。\n");
            } else if (searchuser(newuser.userid) != 0) {   /*( dosearchuser( newuser.userid ) ) midified by dong , 1998.12.2, change getuser -> searchuser , 1999.10.26 */
                prints("此帐号已经有人使用\n");
            } else {
                /*--- ---*/
                struct stat lst;
                time_t lnow;

                lnow = time(NULL);
                sethomepath(genbuf, newuser.userid);
                if (!stat(genbuf, &lst) && S_ISDIR(lst.st_mode)
                        && (lnow - lst.st_ctime < SEC_DELETED_OLDHOME /* 3600*24*30 */)) {
                    prints("目前无法注册帐号%s,请与系统管理人员联系。\n", newuser.userid);
                    sprintf(genbuf, "IP %s new id %s failed[home changed in past 30 days]", getSession()->fromhost, newuser.userid);
                    bbslog("user","%s",genbuf);
                } else {
                    /* etnlegend, 2006.10.14, 新用户可能继承原有同名用户信件... */
                    sethomepath(genbuf,newuser.userid);
                    my_f_rm(genbuf);
                    setmailpath(genbuf,newuser.userid);
                    my_f_rm(genbuf);
                    break;
                }
            }
        }
    }

    newuser.firstlogin = newuser.lastlogin = time(NULL) - 13 * 60 * 24;
    do_try = 0;
    while (1) {
        char passbuf[STRLEN], passbuf2[STRLEN];

        if (++do_try >= 10) {
            prints("\n掰掰,按太多下  <Enter> 了...\n");
            refresh();
            longjmp(byebye, -1);
        }
        getdata(0, 0, "请设定您的密码: ", passbuf, 39, NOECHO, NULL, true);
        if (strlen(passbuf) < 4 || !strcmp(passbuf, newuser.userid)) {
            prints("密码太短或与使用者代号相同, 请重新输入\n");
            continue;
        }
        getdata(0, 0, "请再输入一次你的密码: ", passbuf2, 39, NOECHO, NULL, true);
        if (strcmp(passbuf, passbuf2) != 0) {
            prints("密码输入错误, 请重新输入密码.\n");
            continue;
        }

        setpasswd(passbuf, &newuser);
#ifdef NEWSMTH
        strcpy(getSession()->passwd, passbuf);
#endif
        break;
    }

    if (searchuser(newuser.userid) != 0) {
        prints("此帐号已经有人使用\n");
        refresh();
        longjmp(byebye, -1);
    }

    newuser.userlevel = PERM_BASIC;
    newuser.userdefine[0] = -1;
    newuser.userdefine[1] = -1;
    /*   newuser.userdefine&=~DEF_MAILMSG;
        newuser.userdefine&=~DEF_EDITMSG; */
    SET_UNDEFINE(&newuser, DEF_NOTMSGFRIEND);
    if (convcode)
        SET_UNDEFINE(&newuser, DEF_USEGB);

    SET_UNDEFINE(&newuser, DEF_SHOWREALUSERDATA);

    newuser.exittime = time(NULL) - 100;
    /*newuser.unuse2 = -1;*/
    newuser.flags |= PAGER_FLAG;
    newuser.title = 0;
    newuser.firstlogin = newuser.lastlogin = time(NULL);

    allocid = getnewuserid2(newuser.userid);
    if (allocid > MAXUSERS || allocid <= 0) {
        prints("抱歉, 由于某些系统原因, 无法注册新的帐号.\n\r");
        oflush();
        sleep(2);
        exit(1);
    }
    newbbslog(BBSLOG_USIES, "APPLY: %s uid %d from %s", newuser.userid, allocid, getSession()->fromhost);

    update_user(&newuser, allocid, 1);

    if (!dosearchuser(newuser.userid)) {
        /* change by KCN 1999.09.08
           fprintf(stderr,"User failed to create\n") ;
         */
        prints("User failed to create %d-%s\n", allocid, newuser.userid);
        oflush();
        exit(1);
    }
    bbslog("user","%s","new account");
#endif /* SECONDSITE */
}
Example #10
0
static void login_query() {
    char uid[IDLEN + 1], passbuf[PASSLEN];
    int attempts;
    char genbuf[200];
    extern struct utmpfile_t *utmpshm;
    resolve_utmp();
    attach_uhash();
    attempts = utmpshm->number;
    show_file("etc/Welcome", 1, -1, NO_RELOAD);
    output("1",1);
    if(attempts >= MAX_ACTIVE) {
	outs("由於人數太多,請您稍後再來。\n");
	refresh();
	exit(1);
    }

    /* hint */
    
    attempts = 0;
    while(1) {

	if(attempts++ >= LOGINATTEMPTS) {
	    more("etc/goodbye", NA);
	    pressanykey();
	    exit(1);
	}

	getdata(20, 0, "請輸入代號,或以[guest]參觀,以[new]註冊:",
		uid, IDLEN + 1, DOECHO);
	if(strcasecmp(uid, str_new) == 0) {
#ifdef LOGINASNEW
	    new_register();
	    break;
#else
	    outs("本系統目前無法以 new 註冊, 請用 guest 進入\n");
	    continue;
#endif
	} else if(uid[0] == '\0' || !dosearchuser(uid)) {
	    outs(err_uid);
	} else if(strcmp(uid, STR_GUEST)) {
	    getdata(21, 0, MSG_PASSWD, passbuf, PASSLEN, NOECHO);
	    passbuf[8] = '\0';
	    
	    if(!checkpasswd(cuser.passwd, passbuf) /* ||
	       (HAS_PERM(PERM_SYSOP) && !use_shell_login_mode)*/) {
		logattempt(cuser.userid, '-');
		outs(ERR_PASSWD);
	    } else {
		logattempt(cuser.userid, ' ');
		if(strcasecmp("SYSOP", cuser.userid) == 0)
		    cuser.userlevel = PERM_BASIC | PERM_CHAT | PERM_PAGE |
			PERM_POST | PERM_LOGINOK | PERM_MAILLIMIT |
			PERM_CLOAK | PERM_SEECLOAK | PERM_XEMPT |
			PERM_DENYPOST | PERM_BM | PERM_ACCOUNTS |
			PERM_CHATROOM | PERM_BOARD | PERM_SYSOP |
			PERM_BBSADM;
		break;
	    }
	} else {	/* guest */
	    cuser.userlevel = 0;
	    cuser.uflag = COLOR_FLAG | PAGER_FLAG | BRDSORT_FLAG | MOVIE_FLAG;
	    break;
	}
    }
    multi_user_check();
    sethomepath(genbuf, cuser.userid);
    mkdir(genbuf, 0755);
}
Example #11
0
int
bbslogin_main()
{
	int n, t, infochanged = 0;
	time_t dtime;
	char filename[128], buf[256], id[20], pw[PASSLEN], url[10], *ub =
	    FIRST_PAGE;
	char *ptr;
	char md5pass[MD5LEN];
	struct userec *x, tmpu;
	int ipmask;
	int uid;
	html_header(3);

	if (loginok && !isguest) {
		sprintf(buf, "/" SMAGIC "/?t=%d", (int) now_t);
		redirect(buf);
	}

	strsncpy(id, strtrim(getparm("id")), 13);
	strsncpy(pw, getparm("pw"), PASSLEN);
	strsncpy(url, getparm("url"), 3);
	ipmask = atoi(getparm("ipmask"));
	if (!id[0]) {
		strcpy(id, "guest");
		ipmask = 8;
	}
	if (!strcmp(MY_BBS_ID, "YTHT") && !strcmp(id, "guest")) {
		http_fatal("请输入用户名和密码以登录。");
	}
	if (strcmp(id, "guest")) {
		ipmask = extandipmask(ipmask, getparm("lastip1"), realfromhost);
		ipmask = extandipmask(ipmask, getparm("lastip2"), realfromhost);
	}
	if ((uid = getuser(id, &x)) <= 0) {
		printf("%s<br>", id);
		http_fatal("错误的使用者帐号");
	}
	strcpy(id, x->userid);
	if (strcasecmp(id, "guest")) {
		if (checkbansite(realfromhost)) {
			http_fatal
			    ("对不起, 本站不欢迎来自 [%s] 的登录. <br>若有疑问, 请与SYSOP联系.",
			     realfromhost);
		}
		if (userbansite(x->userid, realfromhost))
			http_fatal("本ID已设置禁止从%s登录", realfromhost);
		if (!checkpasswd(x->passwd, x->salt, pw)) {
			logattempt(x->userid, realfromhost, "WWW", now_t);
			http_fatal
			    ("密码错误,如有疑问请联系站务组,提供注册资料找回密码");
		}
		if (!user_perm(x, PERM_BASIC))
			http_fatal
			    ("由于本帐号名称不符合帐号管理办法,已经被管理员禁止继续上站。<br>请用其他帐号登录在 <font color=red>"
			     DEFAULTBOARD "</font> 版询问.");
		if (file_has_word(MY_BBS_HOME "/etc/prisonor", x->userid)) {
			if (x->inprison == 0) {
				memcpy(&tmpu, x, sizeof (tmpu));
				tmpu.inprison = 1;
				tmpu.dieday = 2;
				updateuserec(&tmpu, 0);
			}
			http_fatal("安心改造,不要胡闹");
		}
		if (x->dieday)
			http_fatal("死了?还要做什么? :)");
		t = x->lastlogin;
		memcpy(&tmpu, x, sizeof (tmpu));
		if (tmpu.salt == 0) {
			tmpu.salt = getsalt_md5();
			genpasswd(md5pass, tmpu.salt, pw);
			memcpy(tmpu.passwd, md5pass, MD5LEN);
			infochanged = 1;
		}
		if (count_uindex(uid) == 0) {
			if (now_t - t > 1800)
				tmpu.numlogins++;
			infochanged = 1;
			tmpu.lastlogin = now_t;
			dtime = t - 4 * 3600;
			t = localtime(&dtime)->tm_mday;
			dtime = now_t - 4 * 3600;
			if (t < localtime(&dtime)->tm_mday
			    && x->numdays < 60000) {
				tmpu.numdays++;
			}
		}
		if (abs(t - now_t) < 5) {
			http_fatal("两次登录间隔过密!");
		}

		if (x->lasthost != from_addr.s_addr) {
			tmpu.lasthost = from_addr.s_addr;
			infochanged = 1;
		}
		if (infochanged)
			updateuserec(&tmpu, 0);
		currentuser = x;
	}
	ptr = getsenv("HTTP_X_FORWARDED_FOR");
	tracelog("%s enter %s www %d %s", x->userid, realfromhost, infochanged,
		 ptr);
	n = 0;
	if (loginok && isguest) {
		u_info->wwwinfo.iskicked = 1;
	}
	if (strcasecmp(id, "guest")) {
		sethomepath(filename, x->userid);
		mkdir(filename, 0755);

		strsncpy(buf, getparm("style"), 3);
		wwwstylenum = -1;
		if (isdigit(buf[0]))
			wwwstylenum = atoi(buf);
		if ((wwwstylenum > NWWWSTYLE || wwwstylenum < 0))
			if (!readuservalue
			    (x->userid, "wwwstyle", buf, sizeof (buf)))
				wwwstylenum = atoi(buf);
		if (wwwstylenum < 0 || wwwstylenum >= NWWWSTYLE)
			wwwstylenum = 1;
		currstyle = &wwwstyle[wwwstylenum];
	} else {
		wwwstylenum = 1;
		currstyle = &wwwstyle[wwwstylenum];

	}
	ub = wwwlogin(x, ipmask);
#ifdef USESESSIONCOOKIE
	{
		extern char sessionCookie[];
		printf
		    ("<script>document.cookie='SESSION=%s; path=/';</script>",
		     urlencode(sessionCookie));
	}
#endif
	if (!strcmp(url, "1")) {
#if 1
		printf
		    ("<script>\n"
		     "function URLencode(sStr) {\n"
		     "return escape(sStr).replace(/\\+/g, '%%2C').replace(/\\\"/g,'%%22').replace(/\\'/g, '%%27');\n"
		     "}\n"
		     "a=window.opener.location.href;\n" "l=a.length;\n"
		     "t=a.indexOf('/" SMAGIC "',1);\n" "t=a.indexOf('/',t+1);\n"
		     //"nu=\"%s\"+\"?t=%ld&b=\"+URLencode(a.substring(t+1,l));\n"
		     "nu=\"%s\"+\"?t=%ld&b=\"+a.substring(t+1,l);\n"
		     "opener.top.location.href=nu;window.close();</script>",
		     ub, now_t);
#else
		printf
		    ("<script>opener.top.location.href='%s?t=%d';window.close();</script>",
		     ub, now_t);
#endif
	} else {
		char buf[256];
		if (strcmp(x->userid, "guest") && shouldbroadcast(uid))
			sprintf(buf, "%s?t=%d&b=ooo", ub, (int) now_t);
		else
			sprintf(buf, "%s?t=%d", ub, (int) now_t);
		redirect(buf);
	}
	http_quit();
	return 0;
}
Example #12
0
int deal_gopherkey(char ch, int allnum, int pagenum)
{
	char    fname[STRLEN], fpath[STRLEN];
#ifdef INTERNET_EMAIL

	struct shortfile fhdr;
#endif

	switch (ch)
	{
	case 'h':
	case 'H':
		show_help("help/announcereadhelp");
		g_refresh();
		break;
	case 'E':
	case 'e':
		tmpitem = nth_item(allnum - pagenum);
		setuserfile(fname, "gopher.tmp");
		if (tmpitem->title[0] != '0')
		{
			return 1;
		}
		if (get_con(tmpitem->server, tmpitem->port) == -1)
			return 1;
		enterdir(tmpitem->file);
		savetmpfile(fname);
		if (dashf(fname))
		{
			vedit(fname, NA, YEA);
			unlink(fname);
			g_refresh();
		}
		show_message(NULL);
		break;
	case '=':
		{
			tmpitem = nth_item(allnum - pagenum);
			move(2, 0);
			clrtobot();
			prints("");
			printdash("BBS Gopher Îï¼þ»ù±¾×ÊÁÏ");
			prints("");
			prints("ÀàÐÍ£º%c (%s)\n", tmpitem->title[0], (tmpitem->title[0] == '0') ? "Îļþ" : "Ŀ¼");
			prints("±êÌ⣺%s\n", tmpitem->title + 1);
			prints("·¾¶£º%s\n", tmpitem->file);
			prints("λÖãº%s\n", tmpitem->server);
			prints("ʹÓãº%d²º\n", tmpitem->port);
			pressanykey();
			g_refresh();
		}
		break;
	case Ctrl('P'):
					tmpitem = nth_item(allnum - pagenum);
		if (!HAS_PERM(PERM_POST))
			break;
		setuserfile(fname, "gopher.tmp");
		if (tmpitem->title[0] != '0')
{
			return 1;
		}
		if (get_con(tmpitem->server, tmpitem->port) == -1)
			return 1;
		enterdir(tmpitem->file);
		savetmpfile(fname);
		if (dashf(fname))
		{
			char    bname[30];
			clear();
			if (get_a_boardname(bname, "ÇëÊäÈëҪתÌùµÄÌÖÂÛÇøÃû³Æ: "))
			{
				move(1, 0);
				sprintf(fpath, "ÄãÈ·¶¨Òª×ªÌùµ½ %s °åÂð", bname);
				if (askyn(fpath, NA, NA) == 1)
				{
					move(2, 0);
					Postfile(fname, bname, tmpitem->title + 1, 2);
					sprintf(fpath, "ÒѾ­°ïÄãתÌùµ½ %s °åÁË...", bname);
					prints(fpath);
					refresh();
					sleep(1);
				}
			}
		}
		unlink(fname);
		g_refresh();
		return 1;
#ifdef INTERNET_EMAIL

	case 'U':
	case 'F':
	case 'u':
	case 'f':
	case 'z':
	case 'Z':
		tmpitem = nth_item(allnum - pagenum);
		setuserfile(fname, "gopher.tmp");
		if (tmpitem->title[0] != '0')
		{
			return 1;
		}
		if (get_con(tmpitem->server, tmpitem->port) == -1)
			return 1;
		enterdir(tmpitem->file);
		savetmpfile(fname);
		if (dashf(fname))
		{
			strncpy(fhdr.title, tmpitem->title + 1, 70);
			strncpy(fhdr.filename, "gopher.tmp", STRLEN);
			sethomepath(fpath, currentuser.userid);
			//			if (ch == 'Z' || ch == 'z')
			//				a_download(fname);
			//			else {
			switch (doforward(fpath, &fhdr, (ch == 'u' || ch == 'U') ? 1 : 0))
			{
			case 0:
				show_message("ÎÄÕÂת¼ÄÍê³É!");
				break;
			case -1:
				show_message("system error!!.");
				break;
			case -2:
				show_message("invalid address.");
				break;
			default:
				show_message("È¡Ïûת¼Ä¶¯×÷.");
			}
			//			}
			refresh();
			pressanykey();
			g_refresh();
			unlink(fname);
			return 1;
		}
		else
			return 1;
		break;
#endif

	default:
		return 0;
	}
	return 1;
}
Example #13
0
void new_register(void)
{
	char userid[IDLEN + 1], passwd[PASSLEN], passbuf[PASSLEN], log[STRLEN];
#ifndef FDQUAN
	char code[IDLEN+1];
	const char *verify_num;
	int sec;
#endif

	if (dashf("NOREGISTER")) {
		ansimore("NOREGISTER", NA);
		pressreturn();
		return;
	}

	ansimore("etc/register", NA);

#ifndef FDQUAN
	if (!askyn("���Ƿ�ͬ�ⱾվAnnounce�澫����x-3Ŀ¼����վ��?", false, false))
		return 0;
#endif

	int tried = 0;
	prints("\n");
	while (1) {
		if (++tried >= 9) {
			prints("\n�ݰݣ���̫����  <Enter> ��...\n");
			refresh();
			return;
		}

#ifndef FDQUAN
		verify_num = generate_verify_num();
		getdata(0, 0, "������������ʾ������: ", code, IDLEN + 1, DOECHO, YEA);
#endif

		getdata(0, 0, "�������ʺ����� (Enter User ID, \"0\" to abort): ",
				userid, sizeof(userid), DOECHO, YEA);
		if (userid[0] == '0')
			return;
		const char *errmsg = invalid_userid(userid);
		if (errmsg != NULL) {
			outs(errmsg);
			continue;
		}

#ifndef FDQUAN
		sec = random() % 5;
		prints("Ϊ����������ע���߳�ͻ...�����ĵȺ� %d ��...\n", sec);
		oflush();
		sleep(sec);

		if (strcmp(verify_num, code)) {
			snprintf(log, sizeof(log), "verify '%s' error with code %s!=%s from %s",
					userid, verify_num, code, fromhost);
			report(log, currentuser.userid);
			prints("��Ǹ, ���������֤�벻��ȷ.\n");
			continue;
		}

		snprintf(log, sizeof(log), "verify '%s' with code %s from %s ", userid,
				code, fromhost);
		report(log, currentuser.userid);
#endif

		char path[HOMELEN];
		sethomepath(path, userid);
		if (dosearchuser(userid, &currentuser, &usernum) || dashd(path))
			prints("���ʺ��Ѿ�����ʹ��\n");
		else
			break;
	}

	for (tried = 0; tried <= MAX_SET_PASSWD_TRIES; ++tried) {
		passbuf[0] = '\0';
		getdata(0, 0, "���趨�������� (Setup Password): ", passbuf,
				sizeof(passbuf), NOECHO, YEA);
		if (strlen(passbuf) < 4 || !strcmp(passbuf, userid)) {
			prints("����̫�̻���ʹ���ߴ�����ͬ, ����������\n");
			continue;
		}
		strlcpy(passwd, passbuf, PASSLEN);
		getdata(0, 0, "��������һ���������� (Reconfirm Password): ", passbuf,
				PASSLEN, NOECHO, YEA);
		if (strncmp(passbuf, passwd, PASSLEN) != 0) {
			prints("�����������, ��������������.\n");
			continue;
		}
		passwd[8] = '\0';
		break;
	}
	if (tried > MAX_SET_PASSWD_TRIES)
		return;

	struct userec newuser;
#ifdef ALLOWSWITCHCODE
	fill_new_userec(&newuser, userid, passwd, !convcode);
#else
	fill_new_userec(&newuser, userid, passwd, true);
#endif

	/* added by roly */
	sprintf(genbuf, "/bin/rm -fr %s/mail/%c/%s", BBSHOME,
			toupper(newuser.userid[0]), newuser.userid) ;
	system(genbuf);
	sprintf(genbuf, "/bin/rm -fr %s/home/%c/%s", BBSHOME,
			toupper(newuser.userid[0]), newuser.userid) ;
	system(genbuf);
	/* add end */

	int allocid = getnewuserid();
	if (allocid > MAXUSERS || allocid <= 0) {
		prints("No space for new users on the system!\n\r");
		return;
	}
	setuserid(allocid, newuser.userid);
	if (substitut_record(PASSFILE, &newuser, sizeof(newuser), allocid) == -1) {
		prints("too much, good bye!\n");
		return;
	}
	if (!dosearchuser(newuser.userid, &currentuser, &usernum)) {
		prints("User failed to create\n");
		return;
	}

	snprintf(log, sizeof(log), "new account from %s", fromhost);
	report(log, currentuser.userid);

	prints("�����µ�¼ %s ����дע����Ϣ\n", newuser.userid);
	pressanykey();
	return;
}
Example #14
0
static void
login_query()
{
	char		uid       [IDLEN + 1], passbuf[PASSLEN];
	int		attempts;
	char		genbuf    [200];

	resolve_utmp();
	attempts = utmpshm->number;
	clear();

#ifdef CAMERA
	film_out(time(0) % 5, 0);
#else
	show_file("etc/Welcome0", 0, 20, ONLY_COLOR);
#endif

	if (attempts >= MAXACTIVE) {
		pressanykey("目前站上人數已達上限,請您稍後再來。");
		oflush();
		sleep(1);
		exit(1);
	}
	attempts = 0;
	while (1) {
		if (attempts++ >= LOGINATTEMPTS) {
			more("etc/goodbye", NA);
			pressanykey_old("錯誤太多次,掰掰~~~~~");
			exit(1);
		}
		uid[0] = '\0';
		getdata(22, 2, "您的代號:", uid, IDLEN + 1, DOECHO, 0);
		if (strcasecmp(uid, str_new) == 0) {

#ifdef LOGINASNEW
			DL_func("SO/register.so:va_new_register", 0);
			break;
#else
			pressanykey("本系統目前無法以 new 註冊, 請用 guest 進入");
			continue;
#endif
		} else if (uid[0] == '\0' /* || !dosearchuser(uid) */ )
			pressanykey(err_uid);
		else if (belong(FN_DISABLED, uid)) {
			pressanykey("該 ID 為本站禁止上站之 ID");
			logattempt(uid, '*');
		} else if (strcmp(uid, STR_GUEST)) {
			getdata(22, 30, "您的密碼:", passbuf, PASSLEN, PASS, 0);
			passbuf[8] = '\0';

			if (!dosearchuser(uid)) {
				logattempt(uid, '!');
				pressanykey(ERR_PASSWD);
			} else if (!chkpasswd(cuser.passwd, passbuf)) {
				logattempt(cuser.userid, '-');
				pressanykey(ERR_PASSWD);
			} else {
				/* SYSOP gets all permission bits */

				if (!strcasecmp(cuser.userid, str_sysop))
					cuser.userlevel = ~0;

				logattempt(cuser.userid, ' ');
				break;
			}
		} else {
			/* guest 的話 */
#ifdef LOGINASGUEST
			cuser.userlevel = 0;
			cuser.uflag = COLOR_FLAG | PAGER_FLAG | BRDSORT_FLAG | MOVIE_FLAG;
			break;
#else
			pressanykey("本站不提供 guest 上站");
			continue;
#endif
		}
	}

	multi_user_check();
	sethomepath(genbuf, cuser.userid);
	mkdir(genbuf, 0755);
	srand(time(0) ^ getpid() ^ (getpid() << 10));
	srandom(time(0) ^ getpid() ^ (getpid() << 10));
}
Example #15
0
int
bbsleft_main()
{
	int i;
	int div = 0;
//	changemode(MMENU);
	if (0)
		errlog("%s-%s-%s-%s", getsenv("HTTP_ACCEPT_LANGUAGE"),
		       getsenv("Accept"), getsenv("Accept-Charset"),
		       getsenv("Accept-Encoding"));
	html_header(2);
#if 0
	{
		char *ptr;
		char buf[256];
		ptr = getsenv("HTTP_USER_AGENT");
		sprintf(buf, "%-14.14s %.100s", currentuser->userid, ptr);
		addtofile(MY_BBS_HOME "/browser.log", buf);
	}
#endif
	printf("<script src=" BBSLEFTJS "></script>\n"
		"<script src=" BBSJS "></script>\n"
		"<script src=" BBSAJAXJS "></script>\n"
		"<script src=" BBSJSONJS "></script>\n"
		"<script src=" BBSBRDJS "></script>\n"
	       "<body onMouseOver='doMouseOver()' "
	       "onMouseEnter='doMouseOver()' "
	       "onMouseOut='doMouseOut()'>\n<nobr>");
	if (!loginok || isguest) {
		printf("<table width=100%%>\n");
/*由于去掉了框架,暂时去掉https的跳转支持
#ifdef HTTPS_DOMAIN
#ifdef USESESSIONCOOKIE
		printf("<form name=l action=https://%s/" SMAGIC "/bbslogin "
				"method=post target=_top>", 
				getsenv("HTTP_HOST"));
#else
		printf("<form name=l action=https://" HTTPS_DOMAIN
		       "/" SMAGIC "/bbslogin method=post target=_top>");
#endif
		printf("<input type=hidden name=usehost "
				"value='http%s://%s:%s'>",
		       strcasecmp(getsenv("HTTPS"), "ON")?"":"s",
		       getsenv("HTTP_HOST"), getsenv("SERVER_PORT"));
#else
		printf("<form name=l action=bbslogin method=post target=_top>");
#endif
*/
		printf("<form name=l action=bbslogin method=post target=_top>");
		printf("<tr><td>"
		       "<input type=hidden name=lastip1 value=''>"
		       "<input type=hidden name=lastip2 value=''>"
		       "帐号<input type=text name=id maxlength=%d size=11><br>"
		       "密码<input type=password name=pw maxlength=%d size=11><br>"
		       "<a href=/ipmask.html target=_blank>范围</a>"
			"<select name=ipmask style='width: 78px;'>\n"
		       "<option value=0 selected>单IP</option>\n"
		       "<option value=1>2 IP</option>\n"
		       "<option value=2>4 IP</option>\n"
		       "<option value=3>8 IP</option>\n"
		       "<option value=4>16 IP</option>\n"
		       "<option value=5>32 IP</option>\n"
		       "<option value=6>64 IP</option>\n"
		       "<option value=7>128 IP</option>\n"
		       "<option value=8>256 IP</option>\n"
		       "<option value=15>32K IP</option></select>"
		       "<input type=submit value=登录>&nbsp;&nbsp;"
		       "<input type=submit value=注册 onclick=\"{top.location.href='/"
		       SMAGIC "/bbsemailreg';return false}\">\n"
		       "</td></tr></form></table>\n", IDLEN, PASSLEN - 1);
	} else {
		char buf[256] = "未注册用户";
		printf
		    ("用户: <a href=bbsqry?userid=%s target=_top>%s</a><br>",
		     currentuser->userid, currentuser->userid);
		if (currentuser->userlevel & PERM_LOGINOK)
			strcpy(buf, cuserexp(currentuser->exp_group, countexp(currentuser, 2)));
		if (currentuser->userlevel & PERM_BOARDS)
			strcpy(buf, "版主");
		if (currentuser->userlevel & PERM_XEMPT)
			strcpy(buf, "永久帐号");
		if (currentuser->userlevel & PERM_SYSOP)
			strcpy(buf, "本站站长");
		printf("级别: %s<br>", buf);
		printf("<a href=bbslogout target=_top>注销本次登录</a><br>\n");
	}
	printf("<hr>");
	check_msg();  //如果有新消息,则print链接  
	printf("&nbsp;&nbsp;<a target=_top href=boa?secstr=?>一路bbs导读</a><br>\n");
	printf("&nbsp;&nbsp;<a href=\"/ku\" target=\"_blank\">一路精华区(新)</a><br>\n");
	printf("&nbsp;&nbsp;<a target=_top href=bbs0an>精华公布栏</a><br>\n");
	printf("&nbsp;&nbsp;<a target=_top href=bbstop10>十大热门话题</a><br>\n");
	printf("&nbsp;&nbsp;<a target=_top href=digest?C=0>近日精彩话题</a><br>\n");
#if ENABLE_BLOG
	printf("&nbsp; <a target=_blank href=blogpage>一路博客</a><br>\n");
#endif
//	printf("&nbsp; <a target==_BLANK href=http://yjrg.net/wiki><font color=brown>如故知识库</font></a><br>\n");
	if (loginok && !isguest) {
		char buf[10];
		unsigned int mybrdmode;
		readuservalue(currentuser->userid, "mybrd_mode", 
				buf, sizeof(buf));
		mybrdmode = atoi(buf);
		printdiv(&div, "订阅讨论区");
		bbsmybrd_show_left(mybrdmode);
		printf
		    ("&nbsp;&nbsp;<a target=_top href=bbsboa?secstr=*>预定区总览</a><br>\n");
		printf
		    ("&nbsp;&nbsp;<a target=_top href=bbsmybrd?mode=1>预定管理</a><br>\n");
		printf("</div>\n");
	}
	printdiv(&div, "分类讨论区");
	printsectree(&sectree);
	printf("</div>\n");
#if 0
	printf("<div class=r>");
	for (i = 0; i < sectree.nsubsec; i++) {
		const struct sectree *sec = sectree.subsec[i];
		if (!sec->nsubsec)
			continue;
		printf
		    ("--<a target=_top href=bbsboa?secstr=%s>%s</a><br>\n",
		     sec->basestr, sec->title);
	}
	printf("</div>\n");
#endif
	printdiv(&div, "谈天说地");
	if (loginok && !isguest) {
		printf
		    ("&nbsp;&nbsp;<a href=bbsfriend target=_top>在线好友</a><br>\n");
	}
//      printf
//          ("&nbsp;&nbsp;<a href=bbsufind?search=A&limit=20 target=_top>环顾四方</a><br>\n");
	printf("&nbsp;&nbsp;<a href=bbsqry target=_top>查询网友</a><br>\n");
	if (currentuser->userlevel & PERM_PAGE) {
		printf
		    ("&nbsp;&nbsp;<a href=bbssendmsg target=_top>发送短消息</a><br>\n");
		printf
		    ("&nbsp;&nbsp;<a href=bbsmsg target=_top>查看所有短消息</a><br>\n");
	}
	printf("</div>\n");
	if (loginok && !isguest) {
#ifdef HTTPS_DOMAIN
		char str[STRLEN + 10], *ptr;
		//char taskfile[256];
#endif
		printdiv(&div, "个人设置");
#ifdef HTTPS_DOMAIN
		strsncpy(str, getsenv("SCRIPT_URL"), STRLEN);
		ptr = strrchr(str, '/');
		if (ptr)
			strcpy(ptr, "/bbspwd");
		printf("&nbsp;&nbsp;<a target=_top href=https://" HTTPS_DOMAIN
		       "%s>修改密码</a><br>", str);
#else
		printf("&nbsp;&nbsp;<a target=_top href=bbspwd>修改密码</a><br>");
#endif
		printf("&nbsp;&nbsp;<a target=_top href=bbsinfo>个人资料和头像</a><br>"
		       "&nbsp;&nbsp;<a target=_top href=bbsplan>改说明档</a><br>"
		       "&nbsp;&nbsp;<a target=_top href=bbssig>改签名档</a><br>"
		       "&nbsp;&nbsp;<a target=_top href=bbsparm>修改个人参数</a><br>"
		       "&nbsp;&nbsp;<a target=_top href=bbsmywww>WWW个人定制</a><br>"
		       "&nbsp;&nbsp;<a target=_top href=bbsmyclass>底栏显示的版面</a><br>"
		       "&nbsp;&nbsp;<a target=_top href=bbsnick>临时改昵称</a><br>"
		       "&nbsp;&nbsp;<a target=_top href=bbsstat>排名统计</a><br>"
		       "&nbsp;&nbsp;<a target=_top href=bbsfall>设定好友</a><br>");

		if (currentuser->userlevel & PERM_CLOAK)
			printf("&nbsp;&nbsp;<a target=_top "
			       "onclick='return confirm(\"确实切换隐身状态吗?\")' "
			       "href=bbscloak>切换隐身</a><br>\n");
		printf("</div>");
		printdiv(&div, "处理信件");
		printf("&nbsp;&nbsp;<a target=_top href=bbsnewmail>未读邮件</a><br>"
		       "&nbsp;&nbsp;<a target=_top href=bbsmail>所有邮件</a><br>"
		       "&nbsp;&nbsp;<a target=_top href=bbspstmail>发送邮件</a><br>"
		       "</div>");
//		       "&nbsp;&nbsp;<a target=_top href=bbsspam>垃圾邮件</a><br>"

	}
	printdiv(&div, "特别服务");
	//printf("&nbsp;&nbsp;<a target=_top href=bbssechand>二手市场</a><br>\n");
	printf("&nbsp;&nbsp;<a target=_top href=/wnl.html>万年历</a><br>\n");
	//以下特别服务里注释的地方暂时坏了或者没有打开
	//printf("&nbsp;&nbsp;<a target=_top href=/cgi-bin/cgincce>科技词典</a><br>\n");
	printf
	    ("&nbsp;&nbsp;<a target=_top href=/scicalc.html>科学计算器</a><br>\n");
	//printf("&nbsp;&nbsp;<a target=_top href=/periodic/periodic.html>元素周期表</a><br>\n");
	//printf("&nbsp;&nbsp;<a target=_top href=/cgi-bin/cgiman>Linux手册查询</a><br>\n");
	printf("&nbsp;&nbsp;<a href=bbsfind target=_top>文章查询</a><br>\n");
	//printf("&nbsp;&nbsp;<a target=_top href=/cgi-bin/cgifreeip>IP地址查询</a><br>\n");
	//printf("&nbsp;&nbsp;<a target=_top href=bbs0an>精华公布栏</a><br>\n");
	//printf("&nbsp;&nbsp;<a target=_top href=bbsx?chm=1>下载精华区</a><br>\n");
	//printf("&nbsp;&nbsp;<a target=_top href=http://%s/tools/telnet_tools/index.html>" "Telnet工具下载</a><br>\n", getsenv("HTTP_HOST"));
	printf("</div>\n");
if (loginok && !isguest &&
                    (currentuser->userlevel & PERM_DEFAULT) == PERM_DEFAULT) {
	printdiv(&div, "我的地盘");
  if (*system_load() >= 1.7 || count_online() > ONLINELIMIT)
	     printf("&nbsp;&nbsp;我的帖子(系统负载过高,暂停使用)<br>\n");
  else
  	   printf("&nbsp;&nbsp;<a target=_top href=bbsfind?user=%s&amp;day=180>我的帖子</a><br>\n",currentuser->userid);
#ifdef ENABLE_BLOG  	   
  if (currentuser->hasblog)
	printf("&nbsp;&nbsp;<a target=_top href=blog?U=%s>我的Blog</a><br>\n",currentuser->userid);
#endif
		if (isalpha(currentuser->userid[0]) && (currentuser->userlevel & PERM_SPECIAL8)) {
		printf
		    ("&nbsp;&nbsp;<a target=_top href=bbs0an?path=/groups/GROUP_0/Personal_Corpus/%c/%s>我的文集</a>",
		     toupper(currentuser->userid[0]), currentuser->userid);
	}
}
	printf("</div>\n");
	printf("<div class=r>");
//	printf("&nbsp;&nbsp;<a target=_top href=bbs0an?path=/groups/GROUP_0/Personal_Corpus>个人文集区</a><br>\n");
	printf("&nbsp;&nbsp;<a target=_top href=bbsall>所有讨论区</a><br>\n");
	#ifdef ENABLE_INVITATION
                if (loginok && !isguest &&
                    (currentuser->userlevel & PERM_DEFAULT) == PERM_DEFAULT)
                        printf
                            ("&nbsp;&nbsp;<a target=_top href=bbsinvite>邀请朋友</a><br>");
	#endif

	bbsadv_show(2);
	printf("<hr>");
	printf("<table width=100%%><tr><form action=bbssearchboard method=post target=_top><td><div align=center>"
		"<input type=text style='width:100px' name=match maxlength=24 "
		"size=9 value=搜索讨论区 onclick=\"this.select()\" align=left></div></td></form></tr></table>\n");
	printf("<hr>");
	printf("&nbsp;&nbsp;<a href='telnet:%s'>Telnet登录</a><br>\n", BBSHOST);
	printf("&nbsp;&nbsp;<a target=_top href=home?B=BBSHelp>用户帮助</a>\n");
#if 0	/* 先去掉,有空改成再发送一次注册确认信 */
	if (loginok && !isguest && !(currentuser->userlevel & PERM_LOGINOK)
	    && !has_fill_form(currentuser->userid))
		printf
		    ("<br>&nbsp;&nbsp;<a target=_top href=bbsform><font color=red>填写注册单</font></a>\n");
#endif
	if (loginok && !isguest && USERPERM(currentuser, PERM_ACCOUNTS))
		printf
		    ("<br>&nbsp;&nbsp;<a href=bbsscanreg target=_top>SCANREG</a>");
	if (loginok && !isguest && USERPERM(currentuser, PERM_SYSOP))
		printf("<br>&nbsp;&nbsp;<a href=kick target=_top>踢www下站</a>");
	//if(loginok && !isguest) printf("<br>&nbsp;&nbsp;<a href='javascript:openchat()'>bbs茶馆</a>");
	printf
	    ("<br>&nbsp;&nbsp;<a href=bbsselstyle target=_top>换个界面看看</a>");
	printf("<br>&nbsp;&nbsp;当前在线[%d] ", count_online());
	printf("<hr />\n");
	printf("<!-- SiteSearch Google --><form method=\"get\" action=\"http://www.google.com/custom\" target=\"google_window\"><table border=\"0\"><tr><td nowrap=\"nowrap\" valign=\"top\" align=\"left\" height=\"32\"></td><td nowrap=\"nowrap\"><input type=\"hidden\" name=\"domains\" value=\"yilubbs.com\"></input><label for=\"sbi\" style=\"display: none\">输入您的搜索字词</label><input type=\"text\" name=\"q\" size=\"15\" maxlength=\"255\" value=\"\" id=\"sbi\"></input></td></tr><tr><td>&nbsp;</td><td nowrap=\"nowrap\"><table><tr><td><input type=\"radio\" name=\"sitesearch\" value=\"yilubbs.com\" id=\"ss1\" checked></input><label for=\"ss1\" title=\"搜索 yilubbs.com\"><font size=\"-1\" color=\"#000000\">yilubbs.com</font></label></td><td></td></tr></table><label for=\"sbb\" style=\"display: none\">提交搜索表单</label><input type=\"submit\" name=\"sa\" value=\"Google 搜索\" id=\"sbb\"></input><input type=\"hidden\" name=\"client\" value=\"pub-7608613947207155\"></input><input type=\"hidden\" name=\"forid\" value=\"1\"></input><input type=\"hidden\" name=\"ie\" value=\"GB2312\"></input><input type=\"hidden\" name=\"oe\" value=\"GB2312\"></input><input type=\"hidden\" name=\"cof\" value=\"GALT:#008000;GL:1;DIV:#FFFFFF;VLC:663399;AH:center;BGC:FFFFFF;LBGC:FFFFFF;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;LH:50;LW:110;L:http://www.yilubbs.com/ku/images/logo.gif;S:http://www.yilubbs.com;FORID:1\"></input><input type=\"hidden\" name=\"hl\" value=\"zh-CN\"></input></td></tr></table></form><!-- SiteSearch Google -->");
	/*
	printf("<hr />\n"
		"<!-- Google CSE Search Box Begins -->\n"
		"<div align=center>"
		"<form action=\"/fulltext.htm\" id =\"" SEARCHID "\" "
		"target=_blank>\n"
		"<input type=\"hidden\" name=\"cx\" value=\"" SEARCHID "\" />\n"
		"<input type=\"hidden\" name=\"cof\" value=\"FORID:11\" />\n"
		"<input type=\"text\" name=\"q\" size=\"14\" />\n<br>\n"
		"<input type=\"submit\" name=\"sa\" value=\"全文搜索\" />\n"
		"</form>"
		"<script type=\"text/javascript\" src=\"http://"
		"www.google.com/coop/cse/brand?form=searchbox_" SEARCHID 
		"\">\n</script>\n"
		"</div>"
		"<!-- Google CSE Search Box Ends -->");
	*/
	if (1 || strcmp(MY_BBS_ID, "YTHT"))
		printf("<br><br><center><img src=/coco.gif>");
	else {
		printf
		    ("<br><center><a href=http://www.cbe-amd.com target=_blank><img src=/cbe-amd.gif border=0></a>");
		printf
		    ("<br><center><a href=http://www.amdc.com.cn/products/cpg/amd64/ target=_blank><img src=/AMD64_logo.gif border=0></a>");
	}
	printf ("<br><a target=_top href=bug ><strong>报告Bug</strong></a>");
	printf("</div>");
	printf("<script>if(isNS4) arrange();if(isOP)alarrangeO();</script>");
	if (loginok && !isguest) {
		if (USERPERM(currentuser, PERM_LOGINOK)
		    && !USERPERM(currentuser, PERM_POST))
			printf
			    ("<script>alert('您被封禁了全站发表文章的权限, 请参看sysop版公告, 期满后在sysop版申请解封. 如有异议, 发信给arbitration帐号投诉)</script>\n");
		mails(currentuser->userid, &i);
		if (i > 0)
			printf("<script>alert('您有新信件!')</script>\n");
	}
	// if(loginok&&currentuser.userdefine&DEF_ACBOARD)
	//              printf("<script>window.open('bbsmovie','','left=200,top=200,width=600,height=240');</script>"); 
	//virusalert();
	if (isguest && 0)
		printf
		    ("<script>setTimeout('open(\"regreq\", \"winREGREQ\", \"width=600,height=460\")', 1800000);</script>");
	if (loginok && !isguest) {
		char filename[80];
		sethomepath(filename, currentuser->userid);
		mkdir(filename, 0755);
		sethomefile(filename, currentuser->userid, BADLOGINFILE);
		if (file_exist(filename)) {
			printf("<script>"
			       "window.open('bbsbadlogins', 'badlogins', 'toolbar=0, scrollbars=1, location=0, statusbar=1, menubar=0, resizable=1, width=450, height=300');"
			       "</script>");
		}
	}
	bbsadv_show(0);
	if (!via_proxy && wwwcache->text_accel_port
	    && wwwcache->text_accel_addr.s_addr)
		printf("<script src=http://proxy.%s:%d/testdoc.js></script>",
		       MY_BBS_DOMAIN,
		       wwwcache->text_accel_port);
	else if (via_proxy)
		w_info->doc_mode = 0;
	//printf("<script src=/testdoc.js></script>");
	if (!loginok || isguest)
		setlastip();
	printf("</body></html>");
	return 0;
}
Example #16
0
int
bbslogin_main()
{
	int n, t;
	time_t dtime;
	char filename[128], buf[256], id[20], pw[20], url[10], *ub = FIRST_PAGE; // main_page[STRLEN];
	struct userec *x;
	int ipmask;
	html_header(3);
	strsncpy(id, getparm("id"), 13);
	strsncpy(pw, getparm("pw"), 13);
	strsncpy(url, getparm("url"), 3);
	ipmask = atoi(getparm("ipmask"));

	if (loginok && strcasecmp(id, currentuser.userid) && !isguest) {
		http_fatal
		    ("系统检测到目前你的计算机上已经登录有一个帐号 %s,请先退出.(选择正常logout)",
		     currentuser.userid);
	}
	if (!strcmp(id, "")) {
		strcpy(id, "guest");
	}
	x = getuser(id);
	if (x == 0) {
		printf("%s<br>", id);
		http_fatal("错误的使用者帐号");
	}
	strcpy(id, x->userid);
	if (strcasecmp(id, "guest")) {
		if (checkbansite(fromhost)) {
			http_fatal
			    ("对不起, 本站不欢迎来自 [%s] 的登录. <br>若有疑问, 请与SYSOP联系.",
			     fromhost);
		}
		if (userbansite(x->userid, fromhost))
			http_fatal("本ID已设置禁止从%s登录", fromhost);
		if (!checkpasswd(x->passwd, pw)) {
			logattempt(x->userid, fromhost, "WWW", now_t);
			http_fatal("密码错误");
		}
		if (!user_perm(x, PERM_BASIC))
			http_fatal
			    ("此帐号已被停机, 若有疑问, 请用其他帐号在sysop版询问.");
		if (file_has_word(MY_BBS_HOME "/etc/prisonor", x->userid))
			http_fatal("安心改造,不要胡闹");
		if (x->dietime)
			http_fatal("死了?还要做什么? :)");
		t = x->lastlogin;
		x->lastlogin = now_t;
		if (abs(t - now_t) < 20) {
			http_fatal("两次登录间隔过密!");
		}

		dtime = t - 4 * 3600;
		t = localtime(&dtime)->tm_mday;
		dtime = now_t - 4 * 3600;
		if (t < localtime(&dtime)->tm_mday && x->numdays < 800)
			x->numdays++;
		x->numlogins++;
		strsncpy(x->lasthost, fromhost, 16);
		save_user_data(x);
		currentuser = *x;
	}
	sprintf(buf, "%s enter %s www", x->userid, fromhost);
	newtrace(buf);
	n = 0;
	if (loginok && isguest) {
		bzero(u_info, sizeof (struct user_info));
	}
	if (strcasecmp(id, "guest")) {
		sethomepath(filename, x->userid);
		mkdir(filename, 0755);

		strsncpy(buf, getparm("style"), 3);
		wwwstylenum = -1;
		if (isdigit(buf[0]))
			wwwstylenum = atoi(buf);
		if ((wwwstylenum > NWWWSTYLE || wwwstylenum < 0))
			if (!readuservalue
			    (x->userid, "wwwstyle", buf, sizeof (buf)))
				    wwwstylenum = atoi(buf);
		if (wwwstylenum < 0 || wwwstylenum >= NWWWSTYLE)
			wwwstylenum = 1;
		currstyle = &wwwstyle[wwwstylenum];
	} else {
		wwwstylenum = 1;
		currstyle = &wwwstyle[wwwstylenum];

	}

	ub = wwwlogin(x, ipmask);
	if (!strcmp(url, "1")) 
		/*printf("<link href=\"images/@byron.css\" rel=stylesheet type=\"text/css\">\n
			<frameset cols=135,* frameSpacing=0 frameborder=no id=fs0>\n
			<frame src=\"%sbbsleft?t=%ld\" name=f2 frameborder=no scrolling=no>\n
			<frameset id=fs1 rows=0,*,18 frameSpacing=0 frameborder=no border=0>\n
			<frame scrolling=no name=fmsg src=\"%sbbsmsg\">\n
			<frame name=f3 src=\"%sbbsfoot\">\n
			<frame scrolling=no name=f4 src=\"%sbbsfoot.htm\">\n
			</frameset>\n
			</frameset>\n", ub, now_t, ub, ub, ub);*/			//add by mintbaggio 040411 for new www

	//	html_header(3);

		printf
		    ("<script>opener.parent.f2.location.href=\"%sbbsleft?t=%ld\";\n"
		     "opener.parent.fmsg.location.href=\"%sbbsgetmsg\";\n"
		     //"opener.parent.f4.location.href=\"%sbbsfoot\";\n"
		     "a=window.opener.location.href;\n" "l=a.length;\n"
		     "t=a.indexOf('/" SMAGIC "',1);\n" "t=a.indexOf('/',t+1);\n"
		     "nu=\"%s\"+a.substring(t+1,l);\n"
		     "window.opener.location.href=nu;window.close();</script>",
		     ub, now_t, ub, ub, ub);

		
	//}
	else
		redirect(ub);
	//else {
	//	print_session_string(ub);
	//	html_header(3);
	//	
	//	sprintf(main_page, "/%s/", SMAGIC);
	//	redirect(main_page);
	//}
	http_quit();
	return 0;
}
Example #17
0
static int login_query(void)
{
#ifndef ENABLE_SSH
	char uname[IDLEN + 2];
	char passbuf[PASSLEN];
	int attempts;
	int recover; // For giveupBBS
	bool auth = false;
#endif // ENABLE_SSH

	// Deny new logins if too many users online.
	int online = session_count_online();
#ifndef ENABLE_SSH
	if (online >= MAXACTIVE) {
		ansimore("etc/loginfull", NA);
		return -1;
	}
#endif // ENABLE_SSH

	ansimore2("etc/issue", false, 0, 0);
	screen_printf("\033[1;35m欢迎光临\033[1;40;33m【 %s 】 \033[m"
			"[\033[1;33;41m Add '.' after YourID to login for BIG5 \033[m]\n",
			BBSNAME_UTF8);

	int peak = session_get_online_record();
	if (peak < online) {
		session_set_online_record(online);
		peak = online;
	}

	screen_printf("\033[1;32m目前已有帐号: [\033[1;36m%d\033[32m/\033[36m%d\033[32m] "
			"\033[32m目前站上人数: [\033[36m%d\033[32m/\033[36m%d\033[1;32m]\n",
			get_user_count(), MAXUSERS, online, MAXACTIVE);
	visitlog(peak);

#ifndef ENABLE_SSH
	attempts = 0;
	while (!auth) {
		if (attempts++ >= LOGINATTEMPTS) {
			ansimore("etc/goodbye", NA);
			return -1;
		}
		//% getdata(0, 0, "\033[1;33m请输入帐号\033[m"
		getdata(0, 0, "\033[1;33m\xc7\xeb\xca\xe4\xc8\xeb\xd5\xca\xba\xc5\033[m"
				//% "(试用请输入'\033[1;36mguest\033[m', "
				"(\xca\xd4\xd3\xc3\xc7\xeb\xca\xe4\xc8\xeb'\033[1;36mguest\033[m', "
				//% "注册请输入'\033[1;31mnew\033[m'): ",
				"\xd7\xa2\xb2\xe1\xc7\xeb\xca\xe4\xc8\xeb'\033[1;31mnew\033[m'): ",
				uname, IDLEN + 1, DOECHO, YEA);
		if (strcaseeq(uname, "guest") && (online > MAXACTIVE - 10)) {
			ansimore("etc/loginfull", NA);
			return -1;
		}
		if (strcaseeq(uname, "new")) {
			memset(&currentuser, 0, sizeof(currentuser));
			new_register();
			terminal_flush();
			exit(1);
		} else if (*uname == '\0')
			;
		else if (!dosearchuser(uname, &currentuser, &usernum)) {
			screen_printf("\033[1;31m经查证,无此 ID。\033[m\n");
		} else if (strcaseeq(uname, "guest")) {
			currentuser.userlevel = 0;
			break;
		} else {
			//% getdata(0, 0, "\033[1;37m请输入密码: \033[m", passbuf, PASSLEN,
			getdata(0, 0, "\033[1;37m\xc7\xeb\xca\xe4\xc8\xeb\xc3\xdc\xc2\xeb: \033[m", passbuf, PASSLEN,
					NOECHO, YEA);
			passbuf[8] = '\0';
			switch (bbs_auth(uname, passbuf)) {
				case BBS_EWPSWD:
					screen_printf("\033[1;31m密码输入错误...\033[m\n");
					break;
				case BBS_EGIVEUP:
					recover = chk_giveupbbs();
					screen_printf("\033[33m您正在戒网,离戒网结束还有%d天\033[m\n",
							recover - fb_time() / 3600 / 24);
					return -1;
				case BBS_ESUICIDE:
					screen_printf("\033[32m您已经自杀\033[m\n");
					return -1;
				case BBS_EBANNED:
					screen_printf("\033[32m本帐号已停机。请到 "
							"\033[36mNotice\033[32m版 查询原因\033[m\n");
					return -1;
				case BBS_ELFREQ:
					screen_printf("登录过于频繁,请稍候再来\n");
					return -1;
				case 0:
					auth = true;
					break;
				default:
					auth = false;
					break;
			}
			memset(passbuf, 0, PASSLEN - 1);
		}
	}
#else // ENABLE_SSH
	//% 欢迎使用ssh方式访问本站,请按任意键继续
	presskeyfor("\033[1;33m\xbb\xb6\xd3\xad\xca\xb9\xd3\xc3ssh\xb7\xbd\xca\xbd\xb7\xc3\xce\xca\xb1\xbe\xd5\xbe\xa3\xac\xc7\xeb\xb0\xb4\xc8\xce\xd2\xe2\xbc\xfc\xbc\xcc\xd0\xf8", -1);
#endif // ENABLE_SSH

	if (multi_user_check() == -1)
		return -1;

	sethomepath(genbuf, currentuser.userid);
	mkdir(genbuf, 0755);
	login_start_time = time(NULL);
	return 0;
}
Example #18
0
int uinfo_query(struct userec *u, int real, int unum)
{
	struct userec newinfo;
	char    ans[3], buf[STRLEN], genbuf[128];
	char    src[STRLEN], dst[STRLEN];
	int     i, fail = 0 ;
#ifdef MAILCHANGED

	int    netty_check = 0;
#endif

	time_t  now;
	struct tm *tmnow;
	memcpy(&newinfo, u, sizeof(currentuser));
	getdata(t_lines - 1, 0, real ?
	        "��ѡ�� (0)���� (1)�޸����� (2)�趨���� (3) �� ID ==> [0]" :
	        "��ѡ�� (0)���� (1)�޸����� (2)�趨���� (3) ѡǩ���� ==> [0]",
	        ans, 2, DOECHO, YEA);
	clear();
	refresh();
	now = time(0);
	tmnow = localtime(&now);

	i = 3;
	move(i++, 0);
	if (ans[0] != '3' || real)
		prints("ʹ���ߴ���: %s\n", u->userid);
	switch (ans[0])
	{
	case '1':
		move(1, 0);
		prints("�������޸�,ֱ�Ӱ� <ENTER> ����ʹ�� [] �ڵ����ϡ�\n");
		sprintf(genbuf, "�dz� [%s]: ", u->username);
		getdata(i++, 0, genbuf, buf, NAMELEN, DOECHO, YEA);
		if (buf[0])
			strncpy(newinfo.username, buf, NAMELEN);

		sprintf(genbuf, "��ʵ���� [%s]: ", u->realname);
		getdata(i++, 0, genbuf, buf, NAMELEN, DOECHO, YEA);
		if (buf[0])
			strncpy(newinfo.realname, buf, NAMELEN);

		sprintf(genbuf, "��ס��ַ [%s]: ", u->address);
		getdata(i++, 0, genbuf, buf, STRLEN - 10, DOECHO, YEA);
		if (buf[0])
			strncpy(newinfo.address, buf, NAMELEN);

		sprintf(genbuf, "�������� [%s]: ", u->email);
		getdata(i++, 0, genbuf, buf, 48, DOECHO, YEA);
		if (buf[0])
		{
#ifdef MAILCHECK
#ifdef MAILCHANGED
			if(u->uid == usernum)
				netty_check = 1;
#endif
#endif

			strncpy(newinfo.email, buf, 48);
		}

		sprintf(genbuf, "�ն˻���̬ [%s]: ", u->termtype);
		getdata(i++, 0, genbuf, buf, 16, DOECHO, YEA);
		if (buf[0])
			strncpy(newinfo.termtype, buf, 16);

		sprintf(genbuf, "������ [%d]: ", u->birthyear + 1900);
		getdata(i++, 0, genbuf, buf, 5, DOECHO, YEA);
		if (   buf[0] && atoi(buf) > 1920 && atoi(buf) < 1998)
			newinfo.birthyear = atoi(buf) - 1900;

		sprintf(genbuf, "������ [%d]: ", u->birthmonth);
		getdata(i++, 0, genbuf, buf, 3, DOECHO, YEA);
		if (buf[0] && atoi(buf) >= 1 && atoi(buf) <= 12)
			newinfo.birthmonth = atoi(buf);

		sprintf(genbuf, "������ [%d]: ", u->birthday);
		getdata(i++, 0, genbuf, buf, 3, DOECHO, YEA);
		if (buf[0] && atoi(buf) >= 1 && atoi(buf) <= 31)
			newinfo.birthday = atoi(buf);

		sprintf(genbuf, "�Ա�(M.��)(F.Ů) [%c]: ", u->gender);
		getdata(i++, 0, genbuf, buf, 2, DOECHO, YEA);
		if (buf[0])
		{
			if (strchr("MmFf", buf[0]))
				newinfo.gender = toupper(buf[0]);
		}

		if (real)
			uinfo_change1(i,u,&newinfo);
		break;
	case '2':
		if (!real)
		{
			getdata(i++, 0, "������ԭ����: ", buf, PASSLEN, NOECHO, YEA);
			if (*buf == '\0' || !checkpasswd(u->passwd, buf))
			{
				prints("\n\n�ܱ�Ǹ, ����������벻��ȷ��\n");
				fail++;
				break;
			}
		}
		getdata(i++, 0, "���趨������: ", buf, PASSLEN, NOECHO, YEA);
		if (buf[0] == '\0')
		{
			prints("\n\n�����趨ȡ��, ����ʹ�þ�����\n");
			fail++;
			break;
		}
		strncpy(genbuf, buf, PASSLEN);
		getdata(i++, 0, "����������������: ", buf, PASSLEN, NOECHO, YEA);
		if (strncmp(buf, genbuf, PASSLEN))
		{
			prints("\n\n������ȷ��ʧ��, �޷��趨�����롣\n");
			fail++;
			break;
		}
		buf[8] = '\0';
		strncpy(newinfo.passwd, genpasswd(buf), ENCPASSLEN);
		break;
	case '3':
		if (!real)
		{
			sprintf(genbuf, "Ŀǰʹ��ǩ���� [%d]: ", u->signature);
			getdata(i++, 0, genbuf, buf, 16, DOECHO, YEA);
			if (atoi(buf) > 0)
				newinfo.signature = atoi(buf);
		}
		else
		{
			struct user_info uin;
			extern int t_cmpuids();
			if(t_search_ulist(&uin, t_cmpuids, unum, NA, NA)!=0)
			{
				prints("\n�Բ��𣬸��û�Ŀǰ�������ϡ�");
				fail++;
			}
			else if(!strcmp(lookupuser.userid,"SYSOP"))
			{
				prints("\n�Բ����㲻�����޸� SYSOP �� ID��");
				fail++;
			}
			else
			{
				getdata(i++,0,"�µ�ʹ���ߴ���: ",genbuf,IDLEN+1,DOECHO, YEA);
				if (*genbuf != '\0')
				{
					if (getuser(genbuf))
					{
						prints("\n�Բ���! �Ѿ���ͬ�� ID ��ʹ����\n");
						fail++;
					}
					else
					{
						strncpy(newinfo.userid, genbuf, IDLEN + 2);
					}
				}
				else
					fail ++;
			}
		}
		break;
	default:
		clear();
		return 0;
	}
	if (fail != 0)
	{
		pressreturn();
		clear();
		return 0;
	}
	if (askyn("ȷ��Ҫ�ı���", NA, YEA) == YEA)
	{
		if (real)
		{
			char    secu[STRLEN];
			sprintf(secu, "�޸� %s �Ļ������ϻ����롣", u->userid);
			securityreport1(secu);
		}
		if (strcmp(u->userid, newinfo.userid))
		{
			sprintf(src, "mail/%c/%s", toupper(u->userid[0]), u->userid);
			sprintf(dst, "mail/%c/%s", toupper(newinfo.userid[0]), newinfo.userid);
			rename(src, dst);
			sethomepath(src, u->userid);
			sethomepath(dst, newinfo.userid);
			rename(src, dst);
			sethomefile(src, u->userid, "register");
			unlink(src);
			sethomefile(src, u->userid, "register.old");
			unlink(src);
			setuserid(unum, newinfo.userid);
		}
		if(!strcmp(u->userid, currentuser.userid))
		{
			extern int WishNum;
			strncpy(uinfo.username,newinfo.username,NAMELEN);
			WishNum = 9999;
		}
#ifdef MAILCHECK
#ifdef MAILCHANGED
		if ((netty_check == 1)&&!HAS_PERM(PERM_SYSOP))
		{
			sprintf(genbuf, "%s", BBSHOST);
			if ( (!strstr(newinfo.email, genbuf)) &&
			        (!invalidaddr(newinfo.email)) &&
			        (!invalid_email(newinfo.email)))
			{
				strcpy(u->email, newinfo.email);
				send_regmail(u);
			}
			else
			{
				move(t_lines - 5, 0);
				prints("\n������ĵ����ʼ���ַ ��%s��\n",newinfo.email);
				prints("ˡ���ܱ�վ���ϣ�ϵͳ����Ͷ��ע���ţ������������...\n");
				pressanykey();
				return 0;
			}
		}
#endif
#endif
		memcpy(u, &newinfo, (size_t)sizeof(currentuser));
#ifdef MAILCHECK
#ifdef MAILCHANGED

		if ((netty_check == 1)&&!HAS_PERM(PERM_SYSOP))
		{
			newinfo.userlevel &= ~(PERM_LOGINOK | PERM_PAGE | PERM_MESSAGE);
			sethomefile(src, newinfo.userid, "register");
			sethomefile(dst, newinfo.userid, "register.old");
			rename(src, dst);
		}
#endif
#endif
		substitute_record(PASSFILE, &newinfo, sizeof(newinfo), unum);
	}
	clear();
	return 0;
}