Example #1
0
void
logtimeused()
{
	char buf[1024];
	struct cgi_applet *a = applets;
	while (a->main) {
		sprintf(buf, "%s %d %f %f\n", a->name[0], a->count, a->utime,
			a->stime);
		f_append(MY_BBS_HOME "/gprof/cgirtime", buf);
		a++;
	}
}
Example #2
0
static int write_as(AnalysisResult *as, char *fname, struct fileheader *fh, size_t size, int type) {
	int i;
	char sfile[256], buf[1024];

	for(i=0; i <as->ns; i++) {
		if(as->sid[i] <= 0 || as->sim[i] < 3)
			continue;
		sprintf(sfile, SP_DIR "/%s.txt", sp[(as->sid[i]-1)].title);
		sprintf(buf, "%d\t%s\t%s\t%s\t%d\t%d\t%d\t%d\n", type, fh->title, 
			fname, fh->owner, as->sim[0], 
			(fh->accessed | FH_ATTACHED) ? 1 : 0, 
			(fh->accessed | FH_REPLIED) ? 1 : 0, size);
		f_append(sfile, buf);
	}
	return 0;
}
Example #3
0
//struct file_to_appendix  a;
int main()
{
        FILE *fp;
        char filename[80], dir[80], board[80], title[80], buf[80], *content, vfrom[80];
	char tmpbuf [5], title2 [10];
        char redirfile[80];
        int r, i=0, length=0, sig, mode=0, accessed=0;
        struct fileheader x;
        struct shortfile *brd;
        init_all();
        if(!loginok)
                http_fatal("匆匆过客不能发表文章,请先登录");


        mode=atoi(getparm("mode"));
        if(mode)
                strsncpy(redirfile, getparm("redir"), 20);
        strsncpy(board, getparm("board"), 18);
        strsncpy(vfrom, getparm("vfrom"), 18);
		if (!*vfrom)
		{
			strcpy(vfrom, board);
		}

        if(dashf("NOPOST")&&!HAS_PERM(PERM_OBOARDS)
   		                && insec(1,board) 
          )
                http_fatal("对不起,系统进入只读状态,暂停发表文章.你先四处看看吧");

        /* efan: very faint	*/
        if (dashf ("NOPOST.2") && ! HAS_PERM (PERM_OBOARDS) && (
                                !strcmp (board, "VoiceofNankai") ||
                                !strcmp (board, "Military") ||
                                !strcmp (board, "TaiWan") ||
                                !strcmp (board, "Salon"))
           )
                http_fatal("对不起,本板进入只读状态,暂停发表文章");



        if(!(currentuser.userlevel & PERM_POST)&&strcmp(board, "appeal")&&strcmp(board, "sysop"))
                http_fatal("您尚未通过注册,暂无发表文章权限");

        if(check_post_limit(board)) return 0;

        strsncpy(title, getparm("title"), 50);
	strsncpy (tmpbuf, getparm ("title2"), 5);
	if (tmpbuf [0] != 0)
		sprintf (title2, "【%s】", tmpbuf);
	else
		title2[0] = 0;

	content=getparm("text");
        brd=getbcache(board);
        /* add by wzk for outgo post */
        //out=strlen(getparm("out"));
        //if (!(brd->flag & OUT_FLAG)) out=0;
        /* end */
        if(brd==0)
                http_fatal("错误的讨论区名称");
        strcpy(board, brd->filename);
	//huangxu@070217:no_word_filter flag
	int bd=0; 
        char temp[80];
        if(!(brd->flag2&NOFILTER_FLAG)&&(bad_words(title) || bad_words (tmpbuf) || bad_words(content) )){
                bd=1;		
                printf("您的文章可能包含不便显示的内容,已经提交审核。请返回并进行修改。");
   	        sprintf(temp,"TEMP-%s",board);
                strcpy(board,"TEMP");
        }else
                strcpy(temp,board);

        for(i=0; i<strlen(title); i++)
                if(title[i]<=27 && title[i]>=-1)
                        title[i]=' ';
        sig=atoi(getparm("signature"));

        if(title[0]==0)
                http_fatal("文章必须要有标题");
	if (title2 [0] == 0 && !strcmp (board, "Secondhand"))
		http_fatal ("在Secondhand板请说清楚您的需要!");
	if (tmpbuf [0] != ' ') {
		char tmptmpbuf [80];
		sprintf (tmptmpbuf, "%s%s", title2, title);
		strcpy (title, tmptmpbuf);
	}
        sprintf(dir, "boards/%s/.DIR", board);
        if(bd==0) 
      	  if(!has_post_perm(&currentuser, board))
             	   http_fatal("此讨论区是唯读的, 或是您尚无权限在此发表文章.");
        
	sprintf(filename, "boards/%s/deny_users", board);
        if(file_has_word(filename, currentuser.userid))
                http_fatal("很抱歉, 你被板务人员停止了本板的post权利.");
        if(abs(time(0) - *(int*)(u_info->from+36))<6) {
                *(int*)(u_info->from+36)=time(0);
                http_fatal("两次发文间隔过密, 请休息几秒后再试");
        }
        *(int*)(u_info->from+36)=time(0);
        sprintf(filename, "tmp/%d.%s.tmp", getpid(),currentuser.userid);
        f_append(filename, content);
        accessed=0;
        if(strlen(getparm("noreply"))>0)
                accessed=FILE_NOREPLY;

        int outgo=0;
        if(strlen(getparm("outgo"))>0)     
            outgo=1;

        int attach=atoi(getparm("attach"));
      
        r=0;
        r=post_article2(temp, title, filename, currentuser.userid, currentuser.username, fromhost, sig-1, accessed, attach,outgo);
        if(r<=0)
                http_fatal("内部错误,无法发文");
        char path[STRLEN];
  /*      while( appendix != NULL ) {
                bzero(&a,sizeof(struct appendix));
                strcpy(a.appendixname,appendix);
                a.filename=r;
                a.sign=0;
                strcpy(a.path,board);
                sprintf(path,"%s/file_appendix",UPLOAD_PATH);
                append_record(&a,sizeof(struct appendix),path);
                appendix = strtok( NULL, "," );
        }
*/
        sprintf(buf,"M.%d.A",r);
        brc_init(currentuser.userid, board);
        brc_add_read(buf);
        brc_update(currentuser.userid, board);
        unlink(filename);
        sprintf(buf, "posted WWW '%s' on '%s'", title, board);
        report(buf);
        if(mode==0)
                sprintf(buf, "bbsdoc?board=%s#bottom", vfrom);
        else if(mode==1)
                sprintf(buf, "bbstcon?board=%s&file=%s&vfrom=%s#bottom", board, redirfile, vfrom);
        else if(mode==2)
                sprintf(buf, "bbstdoc?board=%s#bottom", vfrom);
        if(!junkboard(board)) 
	{
                currentuser.numposts++;
                save_user_data(&currentuser);
               // write_posts(currentuser.userid, board, title);
        }
	 if(toptenboard(board))
        {
                 write_posts(currentuser.userid, board, title);
        }

	else if(!strcmp("Blessing",board)) write_posts(currentuser.userid, board, title);
        //  return 0;
        if(bd==0)        redirect(buf);

}
Example #4
0
int wmllogin(char * buf)
{
	char id[IDLEN + 2], pw[20];
	struct userec *x;
	struct user_info * uol[MULTI_LOGINS];
	char buf2[256], filename[256];
	int i, kick;
	page_init(NULL);
	strncpy(id, getparm("id"), IDLEN + 1);
	strncpy(pw, getparm("pw"), 19);
	if (!*pw)
	{
		strncpy(pw, getparm("pw2"), 19);
	}
	kick = atoi(getparm("kick")) - 1;
	if (!strcasecmp(id, "SYSOP"))
	{
		strcpy (buf, "用户SYSOP登录受限。");
		return -65536;
	}
	if(file_has_word(".bad_host", fromhost)) 
	{
		sprintf (buf, "对不起, 本站不欢迎来自 [%s] 的登录。 若有疑问, 请与SYSOP联系,", fromhost);
		return -256;
	}
	if(loginok && strcasecmp(id, currentuser.userid)) 
	{
		sprintf (buf, "系统检测到目前你的计算机上已经登录有一个帐号 %s,请先退出。", currentuser.userid);
		return 1;
	}
	x = getuser(id);
	if (!x)
	{
		strcpy (buf, "错误的使用者帐号");
		return -1;
	}
	sprintf(buf2, "home/%c/%s/badhost", toupper(x->userid[0]), x->userid);
	if(bad_host(fromhost,buf2)) 
	{
		sprintf (buf, "对不起,此帐号已被设定为不可从 [%s] 登录本站。",fromhost);
		return -257;
	}
	if(strcasecmp(id, "guest")) 
	{
		if(!checkpasswd(x->passwd, pw)) 
		{
			if(*pw)
			{
				sleep(2);
				getdatestring (time(0), NA);
				sprintf(buf2, "%-12.12s  %-30s %s[Wap]\n",id, datestring, fromhost);
				sprintf(filename, "home/%c/%s/logins.bad", toupper(x->userid[0]), x->userid);
				f_append(filename, buf2);
			}
			sprintf (buf, "密码错误");
			return -2;
		}
		if (check_login_limit(x))
		{
			strcpy (buf, "此ID在24小时内上站次数过多,请稍候再来。");
			return -4;
		}
		if(!user_perm(x, PERM_BASIC))
		{
			strcpy (buf, "此帐号已被停机。若有疑问,请用其他帐号在sysop版询问。");
			return -5;
		}
		if (check_multi_d(x, uol, kick))
		{
			wml_httpheader();
			wml_head();
			printf ("<card title=\"登录 -- %s\">", BBSNAME);
			printf ("<p>用户%s已经在本站登录了%d个线程,你需要踢掉一个才能登录。<br />", x->userid, MULTI_LOGINS);
			for (i = 0; i < MULTI_LOGINS; i++)
			{
				printf ("#%d %s %s%s 发呆%d分<br />", i, uol[i]->from, uol[i]->mode >= 20000 ? "@" : "", ModeType(uol[i]->mode >= 20000 ? uol[i]->mode - 20000 : uol[i]->mode), (time(0) - uol[i]->idle_time) / 60);
			}
			printf ("踢掉哪个:<select name=\"inp_kick\">");
			for (i = 0; i < MULTI_LOGINS; i++)
			{
				printf ("<option value=\"%d\">%d</option>", i + 1, i + 1);
			}
			printf ("</select><br />");
			printf ("您的密码:<input type=\"password\" maxlength=\"8\" name=\"inp_pw\" /><br />");
			printf ("<anchor><go href=\"login.wml?id=%s\" method=\"post\"><postfield name=\"pw\" value=\"$(inp_pw)\" /><postfield name=\"kick\" value=\"$(inp_kick)\" /></go>登录</anchor></p>", x->userid);
			return 0;
		}
		x->lastlogin = time(0);
    x->numlogins++;
    strsncpy(x->lasthost, fromhost, 17);
    save_user_data(x);
    currentuser = *x;
	}
	report("WapEnter");
	int iutmpnum, iutmpkey;
	if (!wwwlogin(x, &iutmpnum, &iutmpkey))//0 : succeed
	{
		encodingtest();
		sprintf(buf2, "%d", iutmpnum);
		headerCookie("utmpnum", buf2);
		sprintf(buf2, "%d", iutmpkey);
		headerCookie("utmpkey", buf2);
		headerCookie("utmpuserid", currentuser.userid);
		wml_httpheader();
	}
	else
	{
		strcpy (buf, "抱歉,登录人数太多,请稍候再来:(");
		return -65537;
	}
	sprintf (buf, "用户 %s 登录成功。", x->userid);
	wml_head();
	printf ("<card title=\"登录 -- %s\" ontimer=\"%s\">", BBSNAME, "bbsboa.wml");
	printf ("<timer value=\"50\" />");
	printf ("<p>");
	w_hprintf(buf);
	printf ("</p>");
	printf ("<p>跳转中……</p>");
	printf ("<p><anchor><go href=\"%s\" />如果不能自动跳转,请使用此链接。</anchor></p>", "bbsboa.wml");
	return 0;
}
Example #5
0
int main()
{
        FILE *fp,*fp2;
        struct shortfile *brd;
        struct fileheader f;
        struct userec *u;
        char buf[80], dir[80], path[80], board[80], file[80], *id;
	char jdir[80];
        int num=0;
        init_all();
        if(!loginok)
                http_fatal("请先登录");
        id=currentuser.userid;
        strsncpy(board, getparm("board"), 60);
        strsncpy(file, getparm("file"), 20);
        brd=getbcache(board);
        if(strncmp(file, "M.", 2) && strncmp(file, "G.", 2))
                http_fatal("错误的参数");
        if(strstr(file, ".."))
                http_fatal("错误的参数");
        if(brd==0)
                http_fatal("板面错误");
        if(!has_post_perm(&currentuser, board))
                http_fatal("错误的讨论区");
        sprintf(dir, "boards/%s/.DIR", board);
        sprintf(path, "boards/%s/%s", board, file);
	sprintf(jdir, "boards/%s/.junk", board);
        fp=fopen(dir, "r");
        if(fp==0)
                http_fatal("错误的参数");
        while(1) {
                if(fread(&f, sizeof(struct fileheader), 1, fp)<=0)
                        break;
                if(!strcmp(f.filename, file)) {//huangxu@060715:web下删除m文章
                        if((strcasecmp(id, f.owner)||(f.accessed[0]&FILE_MARKED)) && !has_BM_perm(&currentuser, board))
                                http_fatal("你无权删除该文");
		fp2=fopen(jdir, "a");
		fwrite(&f, sizeof(struct fileheader), 1, fp2);
		fclose(fp2);
			if(!HAS_PERM(PERM_SYSOP))//huangxu@060406:deleted、junk已经无用
      				if(strstr(board,"syssecurity")||(!strcmp(board,"Punishment")&&!HAS_PERM(PERM_BLEVELS)))
					http_fatal("你无权删除该文");
			del_record(dir, sizeof(struct fileheader), num);
                        sprintf(buf, "\n※ %s 于 %s 删除·Web[FROM: %s]", currentuser.userid, Ctime(time(0))+4, fromhost);
                        f_append(path, buf);
                /*        if(!strcmp(f.owner, currentuser.userid)) {
                                post_article("junk", f.title, path, f.owner, "", fromhost, -1);
                        } else {
                                post_article("deleted", f.title, path, f.owner, "", fromhost, -1);
                        }*/
                        //unlink(path);
                        printf("删除成功.<br><a href='bbsdoc?board=%s'>返回本讨论区</a>", board);
                        u=getuser(f.owner);
                        if(!junkboard(board) && u) {
                                if(u->numposts>0)
                                        u->numposts--;
                                save_user_data(u);
                        }
                        sprintf(buf, "%s %-12s bbsdel %s\n", Ctime(time(0))+4, id, board);
                        f_append("trace", buf);
                        http_quit();
                }
                num++;
        }
        fclose(fp);
        printf("文件不存在, 删除失败.<br>\n");
        printf("<a href='bbsdoc?board=%s'>返回本讨论区</a>", board);
        http_quit();
}
Example #6
0
int main()
{
    FILE *fp;
    char userid[80], filename[80], dir[80], title[80], title2[80], buf[80], *content;
    int t, i, sig, backup, mode=0;
    struct fileheader x;
    struct userec *u;
    init_all();
    if(!loginok)
        http_fatal("匆匆过客不能写信,请先登录");
    if(!(currentuser.userlevel & PERM_POST))
        http_fatal("您尚未通过注册,暂无发送信件权限");
    modify_mode(u_info,SMAIL+20000);	//bluetent
    strsncpy(userid, getparm("userid"), 40);
    strsncpy(title, getparm("title"), 50);
    backup=strlen(getparm("backup"));
    int listmail=atoi(getparm("listmail"));
    if(!strcmp(userid,"")&&listmail>=1&&listmail<=9)
        //listmail=1
        ;
    else if(!strstr(userid, "@"))
    {
        u=getuser(userid);
        if(u==0)
        {
            http_fatal("收信人帐号不存在.");
        }
        if(strcmp(userid,"guest")==0)
        {
            http_fatal("您不能给guest帐号写信.");
        }
        strcpy(userid, u->userid);
    }
    else if(!isvalidEmail(userid))
    {
        http_fatal("收信人帐号不存在.");

    }
    for(i=0; i<strlen(title); i++)
        if(title[i]<27 && title[i]>=-1)
            title[i]=' ';
    sig=atoi(getparm("signature"));
    //mode=atoi(getparm("mode"));
    content=getparm("text");

    if(title[0]==0)
        strcpy(title, "没主题");
    if(listmail)
        //huangxu@061217:title只有50长,所以加上头也是安全长度之内的
    {
        sprintf(title2,"[群体信件]%s",title);
        strcpy(title,title2);
    }
    sprintf(filename, "tmp/%d.tmp", getpid());
    f_append(filename, content);
    sprintf(title2, "{%s} %s", userid, title);
    title2[70]=0;
    if(backup)
        post_mail(currentuser.userid, title2, filename, currentuser.userid, currentuser.username, fromhost, sig-1,1);
    if(listmail) {//群体信件
        char path[STRLEN];
        if(listmail>1)//huangxu@070425:群信名单
        {
            sprintf(buf, "maillist%d", listmail);
        }
        else
        {
            strcpy(buf, "maillist");
        }
        sethomefile(path, currentuser.userid, buf);
        FILE *listfile=fopen(path,"r");
        if(listfile==NULL) {
            showinfo("不能打开群体信件名单!");
            http_quit();
            return 1;
        }
        printf("开始发送....<br>");
        char *bufid,bufid2[16];
        while(1) {
            bzero(bufid2,16);
            if(fgets(bufid2, 16, listfile)<=0)
                break;
            bufid=trim(bufid2);
            u=getuser(bufid);
            if(u==0) {
                printf("用户%s不存在.<br>",bufid);
                continue;
            }
            strcpy(bufid, u->userid);
            i = post_mail(bufid, title, filename, currentuser.userid, currentuser.username, fromhost, sig-1,1);
            if ( i== -3 )
                printf("[%s]不想收到您的信件,邮件发送失败<br>\n", bufid);
            else
                printf("%s<br>",bufid);
        }
        printf("发送完毕.<br>");

    } else {
        i = post_mail(userid, title, filename, currentuser.userid, currentuser.username, fromhost, sig-1,1);
        /* the next line add by yiyo for deny user's mail */
        if ( i== -3 )
            printf("[%s]不想收到您的信件,邮件发送失败<br>\n", userid);
        // else
        /*add by yiyo for deny user's mail*/
        //if(mode==1) printf("<center>意见或建议发送成功.<br><br>[<a href=javascript:window.close()>关闭本窗口</a>]\n");
        else {
            printf("信件已寄给%s.<br>\n", userid);
            char *appendixlist=getparm("attach");
            char *appendix=strtok(appendixlist,",");
            struct file_to_appendix  a;
            char path[STRLEN];
            if(strstr(userid, "@"))
                strcpy(userid,""); //互联网信件
            while( appendix != NULL ) {
                //bzero(&a,sizeof(struct appendix));
                strcpy(a.appendixname,appendix);
                a.filename=i;
                a.sign=1;
                strcpy(a.path,userid);
                sprintf(path,"%s/file_appendix",UPLOAD_PATH);
                append_record(&a,sizeof(struct appendix),path);
                appendix = strtok( NULL,",");
            }

        }

    }

    if(backup)
        printf("信件已经备份.<br>\n");
    unlink(filename);
    showinfo("恭喜,发送成功!<br><a href=bbsmail>返回收件箱</a>");
    http_quit();
}