Exemple #1
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;
}
Exemple #2
0
/*严格检查精华区路径的合法性*/
unsigned int check_ann(const struct boardheader* bh){
    char buf[PATHLEN],*ptr;
    unsigned int ret,i;
    ret=0;
    sprintf(buf,"%s",bh->ann_path);
    if(!(ptr=strrchr(buf,'/')))
        return 0x080000;
    *ptr++=0;
    /*精华区路径与讨论区名称不符*/
    if(strcmp(bh->filename,ptr))
        ret|=0x010000;
    /*精华区分区错误*/
    for(i=0;groups[i];i++)
        if(!strcmp(groups[i],buf))
            break;
    if(!groups[i])
        ret|=0x020000;
    else
        ret|=(i&0xFFFF);
    /*精华区目录不存在*/
    sprintf(buf,"0Announce/groups/%s",bh->ann_path);
    if(!dashd(buf))
        ret|=0x040000;
    return ret;
}
Exemple #3
0
static int canread(int level, char *path, char * fname, char *title)
{
	char buf[PATHLEN+20];

	if(strlen(path)+strlen(fname) > PATHLEN)
		return 0;

	sprintf(buf,"%s/%s",path,fname);

#ifdef FB2KPC
	if(!strncmp(path,FB2KPC,strlen(FB2KPC))){
		if(fb2kpc_is_owner(buf))
			return 1;
		if(strstr(title,"<secret>"))
			return 0;
	}else{
#endif
	if(level & PERM_BOARDS) return 1;
#ifdef FB2KPC
	}
#endif

	if(dashd(buf)){
		strcat(buf,"/.allow");
		if(!dashf(buf)) return 1;
		if(!seek_in_file(buf,getCurrentUser()->userid)) return 0;
		return 1;
	}
	return 1;
}
Exemple #4
0
//ÈôdstΪĿ¼,ÇÒ²¢·Ç.,..,×îºóÒ»¸ö×Ö·û²»Îª/,
//			½«Æäɾ³ý,³É¹¦·µ»Ø	1
//					 ·ñÔò·µ»Ø	0
int deltree(char *dst) {
	if (strstr(dst, "//") || strstr(dst, "..") || strchr(dst, ' '))
		return 0; /* precaution */
	if (dst[strlen(dst) - 1] == '/')
		return 0;
	if (dashd(dst)) {
		sprintf(genbuf, "/bin/rm -rf %s", dst);
		system(genbuf);
		return 1;
	} else
		return 0;
}
Exemple #5
0
jobjectArray
Java_com_hace_fastwiki_FileBrowse_GetFiles(JNIEnv* env, jobject thiz, jstring path)
{
	int total = 0;
	char buf[_MAX_IMAGE_TOTAL][64], tmp[128];
	jobjectArray ret;

	const char *file = my_get_string(path);

	DIR *dirp;
	struct dirent *d;

	if ((dirp = opendir(file)) == NULL)
		dirp = opendir("/");

	sprintf(buf[total++], "1..");

	while ((d = readdir(dirp))) {
		if (d->d_name[0] == '.')
			continue;

		if (total >= _MAX_IMAGE_TOTAL - 1)
			break;

		snprintf(tmp, sizeof(tmp), "%s/%s", file, d->d_name);
		
		if (dashf(tmp) && access(tmp, R_OK) == 0) {
			if (is_image_fname(d->d_name))
				snprintf(buf[total++], sizeof(buf[0]), "0%s", d->d_name);
		} else if (dashd(tmp) && access(tmp, R_OK | X_OK) == 0) {
			snprintf(buf[total++], sizeof(buf[0]), "1%s", d->d_name);
		}
	}

	closedir(dirp);

	qsort(buf, total, 64, _cmp_file_name);

	ret = env->NewObjectArray(total, env->FindClass("java/lang/String"), 0);

	for (int i = 0; i < total; i++) {
		env->SetObjectArrayElement(ret, i, env->NewStringUTF(buf[i]));
	}

	return ret;
}
Exemple #6
0
static void
a_showname(const menu_t * pm)
{
    char            buf[PATHLEN];
    int             len;
    int             i;
    int             sym;

    move(b_lines - 1, 0);
    snprintf(buf, sizeof(buf),
	     "%s/%s", pm->path, pm->header[pm->now - pm->page].filename);
    if (dashl(buf)) {
	prints("此 symbolic link 名稱為 %s\n",
	       pm->header[pm->now - pm->page].filename);
	if ((len = readlink(buf, buf, PATHLEN - 1)) >= 0) {
	    buf[len] = '\0';
	    for (i = 0; BBSHOME[i] && buf[i] == BBSHOME[i]; i++);
	    if (!BBSHOME[i] && buf[i] == '/') {
		if (HasUserPerm(PERM_BBSADM))
		    sym = 1;
		else {
		    sym = 0;
		    for (i++; BBSHOME "/man"[i] && buf[i] == BBSHOME "/man"[i];
			 i++);
		    if (!BBSHOME "/man"[i] && buf[i] == '/')
			sym = 1;
		}
		if (sym) {
		    vmsgf("此 symbolic link 指向 %s", &buf[i + 1]);
		}
	    }
	}
    } else if (dashf(buf))
	prints("此文章名稱為 %s", pm->header[pm->now - pm->page].filename);
    else if (dashd(buf))
	prints("此目錄名稱為 %s", pm->header[pm->now - pm->page].filename);
    else
	outs("此項目已損毀, 建議將其刪除!");
    pressanykey();
}
Exemple #7
0
int transman(char *path)
{
  char name[128];
  char buf[512], filename[512], *direct="";
  int n=0;
  fileheader_t fh;
  FILE *fp;

  chdir(path);

  fp = fopen(".Names", "r");
  if(fp)
   for(n=0; fgets(buf,512,fp)>0; n++)
   {
     strtok(buf,"\r\n");
     if(buf[0]=='#') continue;
     if(buf[0]=='N') 
        strcpy(name, buf+5);
     else 
       if(buf[0]=='P') 
        { 
         direct = buf+7;
         strcpy(filename, ".");
         stampfile(filename, &fh);
         unlink(filename);
         if(dashd(direct))
                 {
                  sprintf(fh.title, "¡» %s", name);
                  transman(direct);     
                 }
         else
                  sprintf(fh.title, "¡º %s", name);
         rename(direct, filename);
         append_record(".DIR", &fh, sizeof(fh)); 
        }
   }
  chdir("..");
  return n;
}
Exemple #8
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;
}
Exemple #9
0
static void
a_delete(menu_t * pm, const char *backup_dir)
{
    char            fpath[PATHLEN], buf[PATHLEN], cmd[PATHLEN];
    char            ans[4];
    fileheader_t    backup, *fhdr = &(pm->header[pm->now - pm->page]);
    const char *msg_errsync = "刪除檔案失敗,請退回上層目錄後再重試一次",
               *msg_errsync2 = "檔案可能已被它人刪除,請退回上層目錄再重進確認",
               *msg_errbackup = "檔案已刪除但無法備份。請至 " BN_BUGREPORT
                                "報告您試圖刪除檔案的位置。";

    snprintf(fpath, sizeof(fpath),
	     "%s/%s", pm->path, fhdr->filename);
    setadir(buf, pm->path);

    if (fhdr->filename[0] == 'H' && fhdr->filename[1] == '.') {
	getdata(b_lines - 1, 1, "您確定要刪除此精華區連線嗎(Y/N)?[N] ",
		ans, sizeof(ans), LCECHO);
	if (ans[0] != 'y')
	    return;
	if (delete_fileheader(buf, fhdr, pm->now + 1) == -1) {
            vmsg(msg_errsync);
	    return;
        }
    } else if (dashl(fpath)) {
	getdata(b_lines - 1, 1, "您確定要刪除此 symbolic link 嗎(Y/N)?[N] ",
		ans, sizeof(ans), LCECHO);
	if (ans[0] != 'y')
	    return;
	if (delete_fileheader(buf, fhdr, pm->now + 1) == -1) {
            vmsg(msg_errsync);
	    return;
        }
	unlink(fpath);
    } else if (dashf(fpath)) {

	getdata(b_lines - 1, 1, "您確定要刪除此檔案嗎(Y/N)?[N] ", ans,
		sizeof(ans), LCECHO);
	if (ans[0] != 'y')
	    return;

        if (delete_fileheader(buf, fhdr, pm->now + 1) == -1) {
            vmsg(msg_errsync);
            return;
        }

        switch(delete_file_content(buf, fhdr, backup_dir, NULL, 0)) {
            case DELETE_FILE_CONTENT_BACKUP_FAILED:
                vmsg(msg_errbackup);
                break;
            case DELETE_FILE_CONTENT_FAILED:
                vmsg(msg_errsync2);
                break;
            default:
#ifndef USE_TIME_CAPSULE
                // When not using time capsule, .DIR content may be changed in
                // board (BN_DELETE/BN_JUNK) and need to be changed. However
                // since that's going to be deprecated in future, let's have a
                // simple workaround here.
                if (backup_dir) {
                    const char *bn = NULL;
                    if (strstr(backup_dir, "/" BN_JUNK "/"))
                        bn = BN_JUNK;
                    else if (strstr(backup_dir, "/" BN_DELETED "/"))
                        bn = BN_DELETED;
                    if (bn)
                        setbtotal(getbnum(bn));
                }
#endif
                break;
        }

    } else if (dashd(fpath)) {

        // TODO(hungte) We should create a top level folder and move everything
        // inside.

	// XXX we also check PERM_MAILLIMIT here because RMAIL
	// may be not trusted...
	const char *save_bn = ( HasUserPerm(PERM_MAILLIMIT) && (currstat & RMAIL) ) ?
		BN_JUNK : BN_DELETED;

	getdata(b_lines - 1, 1, "您確定要刪除整個目錄嗎(Y/N)?[N] ", ans,
		sizeof(ans), LCECHO);
	if (ans[0] != 'y')
	    return;
	if (delete_fileheader(buf, fhdr, pm->now + 1) == -1) {
            vmsg(msg_errsync);
	    return;
        }

	setapath(buf, save_bn);
	// XXX because this directory will hold folders from entire site,
	// let's allow it to use a large set of file names.
	if (stampadir(buf, &backup, 1) != 0)
	{
	    vmsg("抱歉,系統目前無法刪除資料,請通知站務人員");
	    return;
	}

	snprintf(cmd, sizeof(cmd),
		"rm -rf %s;/bin/mv -f %s %s", buf, fpath, buf);
	system(cmd);

	strlcpy(backup.owner, cuser.userid, sizeof(backup.owner));
	strcpy(backup.title, "◆");
	strlcpy(backup.title + 2, fhdr->title + 2, sizeof(backup.title) - 3);

        // restrict access if source is hidden
        if ((fhdr->filemode & FILE_BM) || (fhdr->filemode & FILE_HIDE))
            backup.filemode |= FILE_BM;

	/* merge setapath(buf, save_bn); setadir(buf, buf); */
	snprintf(buf, sizeof(buf), "man/boards/%c/%s/" FN_DIR,
		*save_bn, save_bn);
	append_record(buf, &backup, sizeof(backup));

    } else {			/* Ptt 損毀的項目 */
	getdata(b_lines - 1, 1, "您確定要刪除此損毀的項目嗎(Y/N)?[N] ",
		ans, sizeof(ans), LCECHO);
	if (ans[0] != 'y')
	    return;
	if (delete_fileheader(buf, fhdr, pm->now + 1) == -1)
	    return;
    }
    pm->num--;
}
Exemple #10
0
void
a_pasteitem(menu_t * pm, int mode)
{
    char            newpath[PATHLEN];
    char            buf[PATHLEN];
    char            ans[2], skipAll = 0, multiple = 0;
    int             i, copied = 0;
    fileheader_t    item;

    CopyQueue *cq;

    move(b_lines - 1, 0);
    if(copyqueue_querysize() <= 0)
    {
	vmsg("請先執行複製(copy)命令後再貼上(paste)");
	return;
    }
    if(mode && copyqueue_querysize() > 1)
    {
	multiple = 1;
	move(b_lines-2, 0); clrtobot();
	outs("c: 對各項目個別確認是否要貼上, z: 全部不貼,同時重設並取消全部標記\n");
	snprintf(buf, sizeof(buf),
		"確定要貼上全部共 %d 個項目嗎 (c/z/y/N)? ",
		copyqueue_querysize());
	getdata(b_lines - 1, 0, buf, ans, sizeof(ans), LCECHO);
	if(ans[0] == 'y')
	    skipAll = 1;
	else if(ans[0] == 'z')
	{
	    copyqueue_reset();
	    vmsg("已重設複製記錄。");
	    return;
	}
	else if (ans[0] != 'c')
	    return;
	clear();
    }
    while (copyqueue_querysize() > 0)
    {
	cq = copyqueue_gethead();
	if(!cq->copyfile[0])
	    continue;
	if(mode && multiple)
	{
	    scroll();
	    move(b_lines-2, 0); clrtobot();
	    prints("%d. %s\n", ++copied,cq->copytitle);

	}

	if (dashd(cq->copyfile)) {
	    for (i = 0; cq->copyfile[i] && cq->copyfile[i] == pm->path[i]; i++);
	    if (!cq->copyfile[i]) {
		vmsg("將目錄拷進自己的子目錄中,會造成無窮迴圈!");
		continue;
	    }
	}
	if (mode && !skipAll) {
	    snprintf(buf, sizeof(buf),
		     "確定要拷貝[%s]嗎(Y/N)?[N] ", cq->copytitle);
	    getdata(b_lines - 1, 0, buf, ans, sizeof(ans), LCECHO);
	} else
	    ans[0] = 'y';
	if (ans[0] == 'y') {
	    strlcpy(newpath, pm->path, sizeof(newpath));

	    if (*cq->copyowner) {
		char           *fname = strrchr(cq->copyfile, '/');

		if (fname)
		    strcat(newpath, fname);
		else
		    return;
		if (access(pm->path, X_OK | R_OK | W_OK))
		    Mkdir(pm->path);
		memset(&item, 0, sizeof(fileheader_t));
		strlcpy(item.filename, fname + 1, sizeof(item.filename));
		memcpy(cq->copytitle, "◎", 2);
		Copy(cq->copyfile, newpath);
	    } else if (dashf(cq->copyfile)) {
		stampfile(newpath, &item);
		memcpy(cq->copytitle, "◇", 2);
                Copy(cq->copyfile, newpath);
	    } else if (dashd(cq->copyfile) &&
		       stampadir(newpath, &item, 0) != -1) {
		memcpy(cq->copytitle, "◆", 2);
		copy_file(cq->copyfile, newpath);
	    } else {
		copyqueue_reset();
		vmsg("無法拷貝!");
		return;
	    }
	    strlcpy(item.owner, *cq->copyowner ? cq->copyowner : cuser.userid,
		    sizeof(item.owner));
	    strlcpy(item.title, cq->copytitle, sizeof(item.title));
	    a_additem(pm, &item);
	    cq->copyfile[0] = '\0';
	}
    }
}
Exemple #11
0
int
a_menu_rec(const char *maintitle, const char *path,
	int lastlevel, int lastbid,
	char *trans_buffer,
	a_menu_session_t *sess,
	const int *preselect,
	// we don't change root's value (but may change root pointer)
	// we may   change parent's value (but never change parent pointer)
	const menu_t *root, menu_t* const parent)
{
    menu_t          me = {0};
    char            fname[PATHLEN];
    int             ch, returnvalue = FULLUPDATE;

    assert(sess);

    // prevent deep resursive directories
    if (strlen(path) + FNLEN >= PATHLEN)
    {
	// it is not save to enter such directory.
	return returnvalue;
    }

    if(trans_buffer)
	trans_buffer[0] = '\0';

    if (parent)
    {
	parent->next = &me;
    } else {
	assert(root == NULL);
	root = &me;
    }

    me.header_size = p_lines;
    me.header = (fileheader_t *) calloc(me.header_size, FHSZ);
    me.path = path;
    strlcpy(me.mtitle, maintitle, sizeof(me.mtitle));
    setadir(fname, me.path);
    me.num = get_num_records(fname, FHSZ);
    me.bid = lastbid;

    /* 精華區-tree 中部份結構屬於 cuser ==> BM */

    if (!(me.level = lastlevel)) {
	char           *ptr;

	// warning: this is only valid for me.level.
	// is_uBM should not do anything except returning test result:
	// for ex, setting user BM permission automatically.
	// such extra behavior will result in any sub-op to have PERM_BM
	// ability, which leads to entering BM board without authority.
	// Thanks to mtdas@ptt for reporting this exploit.
	if (HasBasicUserPerm(PERM_LOGINOK) &&
            !HasUserPerm(PERM_NOCITIZEN) &&
            (ptr = strrchr(me.mtitle, '[')))
	    me.level = is_uBM(ptr + 1, cuser.userid);
    }
    me.page = A_INVALID_PAGE;

    if (preselect && !*preselect)
	preselect = NULL;

    me.now = preselect ? (*preselect -1) : 0;

    for (;;) {
	if (me.now >= me.num)
	    me.now = me.num - 1;
	if (me.now < 0)
	    me.now = 0;

	if (me.now < me.page || me.now >= me.page + me.header_size) {
	    me.page = me.now - ((me.page == 10000 && me.now > p_lines / 2) ?
				(p_lines / 2) : (me.now % p_lines));
	    if (!a_showmenu(&me))
	    {
		// some directories are invalid, restart!
		sess->bReturnToRoot = 1;
		break;
	    }
	}

	if (preselect && *preselect && preselect[1])
	{
	    // if this is not the last preselect entry, enter it
	    ch = KEY_ENTER;
	} else {
	    ch = cursor_key(2 + me.now - me.page, 0);
	}

	if (ch == 'q' || ch == 'Q' || ch == KEY_LEFT)
	    break;

	// TODO maybe we should let 1-9=simple search and z=tree-search
	// TODO or let 'z' prefix means 'back to root'
	if ((ch >= '1' && ch <= '9') || (ch == 'z' || ch == 'Z')) {
	    int n = a_multi_search_num(ch, sess);
	    me.page = A_INVALID_PAGE;
	    if (n > 0)
	    {
		// simple (single) selection
		me.now = n-1;
		me.page = 10000; // I don't know what's the magic value 10000...
	    }
	    else if (n == 0 && sess->z_indexes[0] == 0)
	    {
		// empty/invalid input
	    }
	    else
	    {
		// n == 0 with multiple selects
		preselect = sess->z_indexes;
		if (*preselect < 0)
		{
		    // return to root first?
		    if (parent)
		    {
			sess->bReturnToRoot = 1;
			return DONOTHING;
		    }

		    // already in root
		    preselect ++;
		}

		// handle first preselect (maybe zero due to previous 'already in root')
		if (*preselect > 0)
		    me.now = *preselect - 1;
		else
		    preselect = NULL;
	    }
	    continue;
	}
	switch (ch) {
	case KEY_UP:
	case 'k':
	    if (--me.now < 0)
		me.now = me.num - 1;
	    break;

	case KEY_DOWN:
	case 'j':
	    if (++me.now >= me.num)
		me.now = 0;
	    break;

	case KEY_PGUP:
	case Ctrl('B'):
	    if (me.now >= p_lines)
		me.now -= p_lines;
	    else if (me.now > 0)
		me.now = 0;
	    else
		me.now = me.num - 1;
	    break;

	case ' ':
	case KEY_PGDN:
	case Ctrl('F'):
	    if (me.now < me.num - p_lines)
		me.now += p_lines;
	    else if (me.now < me.num - 1)
		me.now = me.num - 1;
	    else
		me.now = 0;
	    break;

	case KEY_HOME:
	case '0':
	    me.now = 0;
	    break;
	case KEY_END:
	case '$':
	    me.now = me.num - 1;
	    break;

	case '?':
	case '/':
	    if(me.num) {
		me.now = a_searchtitle(&me, ch == '?');
		me.page = A_INVALID_PAGE;
	    }
	    break;
	case 'h':
	    a_showhelp(me.level);
	    me.page = A_INVALID_PAGE;
	    break;

	case Ctrl('W'):
	    a_where_am_i(root, me.now, me.header[me.now - me.page].title);
	    vmsg(NULL);
	    me.page = A_INVALID_PAGE;
	    break;

	case 'e':
	case 'E':
	    snprintf(fname, sizeof(fname),
		     "%s/%s", path, me.header[me.now - me.page].filename);
	    if (dashf(fname) && me.level >= MANAGER) {
		int edflags = 0;
		*quote_file = 0;

# ifdef BN_BBSMOVIE
		if (me.bid && strcmp(getbcache(me.bid)->brdname,
			    BN_BBSMOVIE) == 0)
		{
		    edflags |= EDITFLAG_UPLOAD;
		    edflags |= EDITFLAG_ALLOWLARGE;
		}
# endif // BN_BBSMOVIE

		if (vedit2(fname, NA, NULL, edflags) != -1) {
		    char            fpath[PATHLEN];
		    fileheader_t    fhdr;
		    strlcpy(fpath, path, sizeof(fpath));
		    stampfile(fpath, &fhdr);
		    unlink(fpath);
		    strlcpy(fhdr.filename,
			    me.header[me.now - me.page].filename,
			    sizeof(fhdr.filename));
		    strlcpy(me.header[me.now - me.page].owner,
			    cuser.userid,
			    sizeof(me.header[me.now - me.page].owner));
		    setadir(fpath, path);
		    substitute_record(fpath, me.header + me.now - me.page,
				      sizeof(fhdr), me.now + 1);

		}
		me.page = A_INVALID_PAGE;
	    }
	    break;

	case 't':
	case 'c':
	    if (me.now < me.num) {
		if (!isvisible_man(&me))
		    break;

		snprintf(fname, sizeof(fname), "%s/%s", path,
			 me.header[me.now - me.page].filename);

		/* XXX: dirty fix
		   應該要改成如果發現該目錄裡面有隱形目錄的話才拒絕.
		   不過這樣的話須要整個搜一遍, 而且目前判斷該資料是目錄
		   還是檔案竟然是用 fstat(2) 而不是直接存在 .DIR 內 |||b
		   須等該資料寫入 .DIR 內再 implement才有效率.
		 */
		if( !me.level && !HasUserPerm(PERM_SYSOP) &&
		    (me.bid==0 || !is_BM_cache(me.bid)) && dashd(fname) )
		    vmsg("只有板主才可以拷貝目錄唷!");
		else
		    a_copyitem(fname, me.header[me.now - me.page].title, 0, 1);
		me.page = A_INVALID_PAGE;
		/* move down */
		if (++me.now >= me.num)
		    me.now = 0;
		break;
	    }
	case KEY_ENTER:
	case KEY_RIGHT:
	case 'r':
	    if (me.now >= me.num || me.now < 0)
	    {
		preselect = NULL;
		continue;
	    }
	    else
	    {
		fileheader_t   *fhdr = &me.header[me.now - me.page];
		const int *newselect = preselect ? preselect+1 : NULL;
		preselect = NULL;

		if (!isvisible_man(&me))
		    break;
#ifdef DEBUG
		vmsgf("%s/%s", &path[11], fhdr->filename);;
#endif
		snprintf(fname, sizeof(fname), "%s/%s", path, fhdr->filename);
		if (dashf(fname)) {
		    int             more_result;

		    while ((more_result = more(fname, YEA))) {
			/* Ptt 範本精靈 plugin */
			if (trans_buffer &&
				(currstat == EDITEXP || currstat == OSONG)) {
			    char            ans[4];

			    move(22, 0);
			    clrtoeol();
			    getdata(22, 1,
				    currstat == EDITEXP ?
				    "要把範例加入到文章內嗎?[y/N]" :
				    "確定要選這篇嗎?[y/N]",
				    ans, sizeof(ans), LCECHO);
			    if (ans[0] == 'y') {
				strlcpy(trans_buffer, fname, PATHLEN);
				sess->bReturnToRoot = 1;
				if (currstat == OSONG) {
				    log_filef(FN_USSONG, LOG_CREAT, "%s\n", fhdr->title);
				}
				free(me.header);
				return FULLUPDATE;
			    }
			}
			if (more_result == READ_PREV) {
			    if (--me.now < 0) {
				me.now = 0;
				break;
			    }
			} else if (more_result == READ_NEXT) {
			    if (++me.now >= me.num) {
				me.now = me.num - 1;
				break;
			    }
			    /* we only load me.header_size pages */
			    if (me.now - me.page >= me.header_size)
				break;
			} else
			    break;
			if (!isvisible_man(&me))
			    break;
			snprintf(fname, sizeof(fname), "%s/%s", path,
				 me.header[me.now - me.page].filename);
			if (!dashf(fname))
			    break;
		    }
		} else if (dashd(fname)) {
		    returnvalue = a_menu_rec(me.header[me.now - me.page].title, fname,
			    me.level, me.bid, trans_buffer,
			    sess, newselect, root, &me);

		    if (returnvalue == DONOTHING)
		    {
			// DONOTHING will only be caused by previous a_multi_search_num + preselect.
			assert(sess->bReturnToRoot);

			if (!parent)
			{
			    // we've reached root menu!
			    assert(sess->z_indexes[0] == -1);
			    sess->bReturnToRoot = 0;
			    returnvalue = FULLUPDATE;
			    preselect = sess->z_indexes+1;  // skip first 'return to root'
			    if (*preselect > 0)
				me.now = *preselect-1;
			}
		    } else  {
			returnvalue = FULLUPDATE;
		    }

		    me.next = NULL;
		    /* Ptt  強力跳出recursive */
		    if (sess->bReturnToRoot) {
			free(me.header);
			return returnvalue;
		    }
		}
		me.page = A_INVALID_PAGE;
	    }
	    break;

	case 'F':
	case 'U':
	    if (me.now < me.num) {
                fileheader_t   *fhdr = &me.header[me.now - me.page];
                if (!isvisible_man(&me))
                    break;
		snprintf(fname, sizeof(fname),
			 "%s/%s", path, fhdr->filename);
		if (HasBasicUserPerm(PERM_LOGINOK) && dashf(fname)) {
		    a_forward(path, fhdr, ch /* == 'U' */ );
		    /* By CharlieL */
		} else
		    vmsg("無法轉寄此項目");
		me.page = A_INVALID_PAGE;
	    }

	    break;

	}

	if (me.level >= MANAGER) {
	    switch (ch) {
	    case 'n':
		a_newitem(&me, ADDITEM);
		me.page = A_INVALID_PAGE;
		break;
	    case 'g':
		a_newitem(&me, ADDGROUP);
		me.page = A_INVALID_PAGE;
		break;
	    case 'p':
		a_pasteitem(&me, 1);
		me.page = A_INVALID_PAGE;
		break;
	    case 'f':
		a_editsign(&me);
		me.page = A_INVALID_PAGE;
		break;
	    case Ctrl('P'):
		a_pastetagpost(&me, -1);
		returnvalue = DIRCHANGED;
		me.page = A_INVALID_PAGE;
		break;
	    case Ctrl('A'):
		a_pastetagpost(&me, 1);
		returnvalue = DIRCHANGED;
		me.page = A_INVALID_PAGE;
		break;
	    case 'a':
		a_appenditem(&me, 1);
		me.page = A_INVALID_PAGE;
		break;
	    }

	    if (me.num)
		switch (ch) {
		case 'm':
		    a_moveitem(&me);
		    me.page = A_INVALID_PAGE;
		    break;

		case 'D':
		    /* Ptt me.page = -1; */
		    a_delrange(&me, sess->backup_dir);
		    me.page = A_INVALID_PAGE;
		    break;
		case 'd':
		    a_delete(&me, sess->backup_dir);
		    me.page = A_INVALID_PAGE;
		    break;
		case 'H':
		    a_hideitem(&me);
		    me.page = A_INVALID_PAGE;
		    break;
		case 'T':
		    a_newtitle(&me);
		    me.page = A_INVALID_PAGE;
		    break;
#ifdef CHESSCOUNTRY
		case 'L':
		    a_setchesslist(&me);
		    break;
#endif
		}
	}
	if (me.level >= SYSOP) {
	    switch (ch) {
	    case 'N':
		a_showname(&me);
		me.page = A_INVALID_PAGE;
		break;
	    }
	}
    }
    free(me.header);
    return returnvalue;
}
Exemple #12
0
static void
a_setchesslist(const menu_t * me)
{
    char buf[4];
    char buf_list[PATHLEN];
    char buf_photo[PATHLEN];
    char buf_this[PATHLEN];
    char buf_real[PATHLEN];
    int list_exist, photo_exist;
    fileheader_t* fhdr = me->header + me->now - me->page;
    int n;

    snprintf(buf_this,  sizeof(buf_this),  "%s/%s", me->path, fhdr->filename);
    if((n = readlink(buf_this, buf_real, sizeof(buf_real) - 1)) == -1)
	strcpy(buf_real, fhdr->filename);
    else
	// readlink doesn't garentee zero-ended
	buf_real[n] = 0;

    if (strcmp(buf_real, "chess_list") == 0
	    || strcmp(buf_real, "chess_photo") == 0) {
	vmsg("不需重設!");
	return;
    }

    snprintf(buf_list,  sizeof(buf_list),  "%s/chess_list",  me->path);
    snprintf(buf_photo, sizeof(buf_photo), "%s/chess_photo", me->path);

    list_exist = dashf(buf_list);
    photo_exist = dashd(buf_photo);

    if (!list_exist && !photo_exist) {
	vmsg("此看板非棋國!");
	return;
    }

    getdata(b_lines, 0, "將此項目設定為 (1) 棋國名單 (2) 棋國照片檔目錄:",
	    buf, sizeof(buf), 1);
    if (buf[0] == '1') {
	if (list_exist)
	    getdata(b_lines, 0, "原有之棋國名單將被取代,請確認 (y/N)",
		    buf, sizeof(buf), 1);
	else
	    buf[0] = 'y';

	if (buf[0] == 'y' || buf[0] == 'Y') {
	    Rename(buf_this, buf_list);
	    symlink("chess_list", buf_this);
	}
    } else if (buf[0] == '2') {
	if (photo_exist)
	    getdata(b_lines, 0, "原有之棋國照片將被取代,請確認 (y/N)",
		    buf, sizeof(buf), 1);
	else
	    buf[0] = 'y';

	if (buf[0] == 'y' || buf[0] == 'Y') {
	    if(strncmp(buf_photo, "man/boards/", 11) == 0 && // guarding
		    buf_photo[11] && buf_photo[12] == '/' && // guarding
		    snprintf(buf_list, sizeof(buf_list), "rm -rf %s", buf_photo)
		    == (int)strlen(buf_photo) + 7)
		system(buf_list);
	    Rename(buf_this, buf_photo);
	    symlink("chess_photo", buf_this);
	}
    }
}
Exemple #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;
}
Exemple #14
0
int
m_sob(void)
{
    char genbuf[256], buf[256], userid[25], passbuf[24], msg[2048]="";
    int count=0, i, isimported=0, corrected;
    FILE *fp;
    sobuserec man;
    time4_t d;

    clear();
    move(1,0);

    outs(
 "   請注意 這是只給陽光沙灘使用者!\n"
 "      讓沙灘的使用者轉移個人資產以及重要信用資料, 享有平等安全的環境.\n"
 "      如果您不需要, 請直離開.\n"
 "    -----------------------------------------------------------------\n"
 "    特別叮嚀:\n"
 "      為了帳號安全,您只有連續十次密碼錯誤的機會,請小心輸入.\n"
 "      連續次錯誤您的變身功\能就會被開罰單並直接通知站長.\n"
 "      請不要在變身過程中不正常斷線, 刻意斷線變半獸人站長不救唷.\n"
	);

   if(getkey("是否要繼續?(y/N)")!='y') return 0;
   if(search_ulistn(usernum,2)) 
        {vmsg("請登出其他視窗, 以免變身失敗"); return 0;}
   do
   {
    if(!getdata(10,0, "      沙灘的ID [大小寫要完全正確]:", userid, 20,
	       DOECHO)) return 0;
    if(bad_user_id(userid)) continue;
    sprintf(genbuf, "sob/passwd/%c/%s.inf",userid[0], userid);
    if(!(fp=fopen(genbuf, "r"))) 
       {
        isimported = 1;
        strcat(genbuf, ".done");
        if(!(fp=fopen(genbuf, "r")))
         {
           vmsg("查無此人或已經匯入過..請注意大小寫 ");
           isimported = 0;
           continue;
         }
       }
    count = fread(&man, sizeof(man), 1, fp);
    fclose(fp);
   }while(!count);
   count = 0;
   do{
    if(!getdata(11,0, "      沙灘的密碼:", passbuf, sizeof(passbuf), 
		  NOECHO)) return 0;
    if(++count>=10)
    {
          cuser.userlevel |= PERM_VIOLATELAW;
          cuser.vl_count++;
	  passwd_update(usernum, &cuser);
          post_violatelaw(cuser.userid, "[PTT警察]", "測試帳號錯誤十次",
		          "違法觀察");
          mail_violatelaw(cuser.userid, "[PTT警察]", "測試帳號錯誤十次",
		          "違法觀察");

          return 0;
    }
    if(!(corrected = checkpasswd(man.passwd, passbuf)))
       vmsg("密碼錯誤"); 
   } while(!corrected);
   move(12,0);
   clrtobot();

   if(!isimported)
     {
       if(!dashf(genbuf))  // avoid multi-login
       {
         vmsg("請不要嘗試多重id踹匯入");
         return 0;
       }
       sprintf(buf,"%s.done",genbuf);
       rename(genbuf,buf);
#ifdef MERGEMONEY

   reload_money(); 

   sprintf(buf, 
           "您的沙灘鸚鵡螺 %10d 換算成 " MONEYNAME " 幣為 %9d (匯率 22:1), \n"
           "    沙灘貝殼有 %10d 換算為 " MONEYNAME " 幣為 %9d (匯率 222105:1), \n"
           "    原有 %10d 匯入後共有 %d\n",
	   (int)man.goldmoney, (int)man.goldmoney/22, 
	   (int)man.silvermoney, (int)man.silvermoney/222105,
	   cuser.money,
	   (int)(cuser.money + man.goldmoney/22 + man.silvermoney/222105));
   demoney(man.goldmoney/22 + man.silvermoney/222105 );
   strcat(msg, buf); 
#endif

     i =  cuser.exmailbox + man.exmailbox + man.exmailboxk/2000;
     if (i > MAX_EXKEEPMAIL) i = MAX_EXKEEPMAIL;
     sprintf(buf, "您的沙灘信箱有 %d (%dk), 原有 %d 匯入後共有 %d\n", 
	    man.exmailbox, man.exmailboxk, cuser.exmailbox, i);
     strcat(msg, buf);
     cuser.exmailbox = i;

     if(man.userlevel & PERM_MAILLIMIT)
      {
       sprintf(buf, "開啟信箱無上限\n");
       strcat(msg, buf);
       cuser.userlevel |= PERM_MAILLIMIT;
      }

     if (cuser.firstlogin > man.firstlogin)
	 d = man.firstlogin;
     else
	 d = cuser.firstlogin;
     cuser.firstlogin = d;

     if (cuser.numlogins < man.numlogins)
	 i = man.numlogins;
     else
	 i = cuser.numlogins;

     sprintf(buf, "沙灘進站次數 %d 此帳號 %d 將取 %d \n", man.numlogins,
	   cuser.numlogins, i);
     strcat(msg,buf);
     cuser.numlogins = i;

     if (cuser.numposts < man.numposts )
	 i = man.numposts;
     else
	 i = cuser.numposts;
     sprintf(buf, "沙灘文章次數 %d 此帳號 %d 將取 %d\n", 
                 man.numposts,cuser.numposts,i);
     strcat(msg,buf);
     cuser.numposts = i;
     outs(msg);
     while (search_ulistn(usernum,2)) 
        {vmsg("請將重覆上站其他線關閉! 再繼續");}
     passwd_update(usernum, &cuser);
   }
   sethomeman(genbuf, cuser.userid);
   mkdir(genbuf, 0755);
   sprintf(buf, "tar zxvf %c/%s.tar.gz>/dev/null",
	   userid[0], userid);
   chdir("sob/home");
   system(buf);
   chdir(BBSHOME);

   if (getans("是否匯入個人信箱? (Y/n)")!='n')
   {
	sethomedir(buf, cuser.userid);
	sprintf(genbuf, "sob/home/%c/%s/.DIR",
		userid[0], userid);
	merge_dir(buf, genbuf, 1);
        strcat(msg, "匯入個人信箱\n");
   }
   if(getans("是否匯入個人信箱精華區(個人作品集)? (會覆蓋\現有設定) (y/N)")=='y')
   {
        fileheader_t fh;
        sprintf(buf,
	 "rm -rd home/%c/%s/man>/dev/null ; "
         "mv sob/home/%c/%s/man home/%c/%s>/dev/null;"
         "mv sob/home/%c/%s/gem home/%c/%s/man>/dev/null", 
              cuser.userid[0], cuser.userid,
	      userid[0], userid,
	      cuser.userid[0], cuser.userid,
	      userid[0], userid,
	      cuser.userid[0], cuser.userid);
        system(buf);
        strcat(msg, "匯入個人信箱精華區(個人作品集)\n");
        sprintf(buf,"home/%c/%s/man/gem", cuser.userid[0], cuser.userid);
        if(dashd(buf))
         {
          strcat(fh.title, "◆ 個人作品集");
          strcat(fh.filename, "gem");
          sprintf(fh.owner, cuser.userid);
          sprintf(buf, "home/%c/%s/man/.DIR", cuser.userid[0], cuser.userid);
          append_record(buf, &fh, sizeof(fh));
         }
   }
Exemple #15
0
int IndexAnnounce(char *bname){
	FILE *fp = NULL;
	int i;
	char boardbuf[BUF_SIZE], pathname[PATH_LEN], 
		 genbuf[BUF_SIZE], boardName[BOARD_LEN] ;
	if ((fp = fopen("/home/bbs/0Announce/.Search", "r")) == NULL){
        printf("Cannot find the /home/bbs/0Announce/.Search file \n program will exit. ");
        return 1;
    }
	while(fgets(boardbuf, BUF_SIZE, fp)){
		sscanf(boardbuf, "%s %s\n", boardName, genbuf);
		for (i = 0; i < BOARD_LEN; i++)
				if (boardName[i] == ':'){
						boardName[i] = '\0';
						break;
				}
		if (bname == NULL || !strcmp(bname, boardName)){
//			if (seek_in_file("/home/bbs/etc/AnnIndexExcp",boardName)!=0 && boardmode != 1 )
//				continue;

			sprintf(pathname,"/home/bbs/0Announce/%s",genbuf);
			if (!dashd(pathname)){
				printf("CAN'T FINd %S", pathname);
				continue;
			}

			sprintf(genbuf, "%s/.annIndex", pathname);
			if (!dashd(genbuf)){
				mkdir(genbuf, 0755);
			}
			
			sprintf(genbuf, "%s/.Names", pathname);

			insertFile(genbuf,".annIndex", "【本板精华区索引】                    (BM: BMS)");
			
			sprintf(genbuf, "%s/.annIndex/.index_all", pathname);
			if ((allIndex = fopen(genbuf, "w+")) > 0){
				sprintf(genbuf, "%s/.annIndex/.Names", pathname);
				insertFile(genbuf,".index_all", "精华区总索引");
			}
			
			sprintf(genbuf, "%s/.annIndex/.index_dir", pathname);
			if ((dirIndex = fopen(genbuf, "w+")) > 0){
					sprintf(genbuf, "%s/.annIndex/.Names", pathname);
					insertFile(genbuf,".index_dir", "精华区目录索引");
			}
			
			sprintf(genbuf, "%s/.annIndex/.change_log", pathname);
			if (logChange)
				if((changeFile = fopen(genbuf, "w+")) > 0){
					sprintf(genbuf, "%s/.annIndex/.Names", pathname);
					insertFile(genbuf,".change_log", "六十日精华区整理记录");
				}
			
									
			boardAnnIndex(pathname, 0, "");
			if (logChange)
					fclose(changeFile);
			fclose(allIndex);
			fclose(dirIndex);
		}
    }
	fclose(fp);
}