Exemplo n.º 1
0
/*
 * Change the mode of a file, either adding write permissions, or removing
 * all write permissions.  Either change honors the current umask setting.
 *
 * Don't do anything if PreservePermissions is set to `yes'.  This may
 * have unexpected consequences for some uses of xchmod.
 */
void xchmod (const char *fname, int writable)
{
    struct stat sb;
    mode_t mode;

    if (stat (fname, &sb) < 0)
    {
        if (!noexec)
            error (0, errno, "cannot stat %s", fn_root(fname));
        return;
    }
    if (writable)
    {
        mode = modify_mode(sb.st_mode,
                           ((sb.st_mode & S_IRUSR) ? S_IWUSR : 0)
                           | ((sb.st_mode & S_IRGRP) ? S_IWGRP : 0)
                           | ((sb.st_mode & S_IROTH) ? S_IWOTH : 0), 0);
    }
    else
    {
        mode = modify_mode(sb.st_mode,0,S_IWUSR|S_IWGRP|S_IWOTH);
    }

    TRACE(1,"chmod(%s,%o)",PATCH_NULL(fname),mode);
    if (noexec)
        return;

    if (chmod (fname, mode) < 0)
        error (0, errno, "cannot change mode of file %s", fn_root(fname));
}
Exemplo n.º 2
0
int main()
{
        FILE *fp;
        char *ptr, plan[256], buf[10000];
        init_all();
        printf("<center>\n");
        if(!loginok)
                http_fatal("匆匆过客不能设置说明档,请先登录");
        modify_mode(u_info,USERDEF+20000);	//bluetent
        sprintf(plan, "home/%c/%s/plans", toupper(currentuser.userid[0]), currentuser.userid);
        if(!strcasecmp(getparm("type"), "update"))
                save_plan(plan);
        printf("%s -- 设置个人说明档 [%s]<hr>\n", BBSNAME, currentuser.userid);
        printf("<form method=post action=bbsplan?type=update>\n");
        fp=fopen(plan, "r");
        if(fp) {
                fread(buf, 9999, 1, fp);
                ptr=strcasestr(buf, "<textarea>");
                if(ptr)
                        ptr[0]=0;
                fclose(fp);
        }
        printf("<table width=610 border=1><tr><td>");
        printf("<textarea name=text rows=20 cols=80 wrap=physicle>\n");
        printf(void1(buf));
        printf("</textarea></table>\n");
        printf("<input type=submit value=存盘> ");
        printf("<input type=reset value=复原>\n");
        printf("<hr>\n");
        http_quit();
}
Exemplo n.º 3
0
int main()
{
        char buf[512];
        char file[80];
        char keystr[80]; //关键字
        int has=1;
        init_all();
        if(!loginok)
                http_fatal("您尚未登录");
        modify_mode(u_info,FTPSEARCH);
        strsncpy(keystr, getparm("keystr"), 80);
        printf("<body background=/bg_1.gif bgproperties=fixed>");
        if(!strlen(keystr)) {
                printf("<table width=600 align=center><tr height=150><td align=center valign=bottom style='font-size:14px'><font color=blue>局域网FTP搜索引擎<p><p></font></td></tr>");
                printf("<tr><td align=center style='font-size:14px'><form name=ftpsearch>请输入关键字:<input name=keystr type=text size=50 maxlength=80><input type=submit value=搜索> (<font color=red>%d</font>人在线)</form><script language=javascript>document.ftpsearch.keystr.focus();</script></td></tr>", countuser());
                printf("<tr><td><table><tr>");
                printf("<td><a href=bbsmyftp?type=4>我要加盟</a></td>");
                if(SiteInList(fromhost))
                        printf("<td> | <a href=bbsmyftp>管理站点数据</a> | <a href=bbsmyftp?type=3>已上传数据的站点列表</a></td>");
                printf("</tr></table></td></tr>");
                printf("</tr><tr><td width=80%%>【说明】 本搜索引擎用来查找南开大学校内教育网和宿舍网FTP站点的数据。<br>各位站长可以自行上传自己的站点数据,服务器端对原始数据进行重新编码以供搜索。<br>因该引擎仅依照编码后的数据进行搜索,故不会对网络负载产生影响。</td></tr>");
                printf("</table>");
        } else {
                sprintf(file, "tmp/%d.tmp", getpid());
                search(keystr, file);
                printf("</pre>");
                unlink(file);
        }
        http_quit();
}
Exemplo n.º 4
0
int main()
{
        int type;
        char pw1[20], pw2[20], pw3[20];
        init_all();
        if(!loginok)
                http_fatal("����δ��¼, ���ȵ�¼");
        modify_mode(u_info,USERDEF+20000);	//bluetent
        type=atoi(getparm("type"));
        if(type==0) {
                printf("%s -- �޸����� [�û�: %s]<hr color=green>\n",
                       BBSNAME, currentuser.userid);
                printf("<form action=bbspwd?type=1 method=post>\n");
                printf("��ľ�����: <input maxlength=12 size=12 type=password name=pw1><br>\n");
                printf("���������: <input maxlength=12 size=12 type=password name=pw2><br>\n");
                printf("������һ��: <input maxlength=12 size=12 type=password name=pw3><br><br>\n");
                printf("<input type=submit value=ȷ���޸�>\n");
                http_quit();
        }
        strsncpy(pw1, getparm("pw1"), 13);
        strsncpy(pw2, getparm("pw2"), 13);
        strsncpy(pw3, getparm("pw3"), 13);
        if(strcmp(pw2, pw3))
                http_fatal("�������벻��ͬ");
        if(strlen(pw2)<2)
                http_fatal("������̫��");
        if(!checkpasswd(currentuser.passwd, pw1))
                http_fatal("���벻��ȷ");
        strcpy(currentuser.passwd, crypt1(pw2, pw2));
        save_user_data(&currentuser);
        printf("[%s] �����޸ijɹ�.", currentuser.userid);
}
Exemplo n.º 5
0
int main()
{
        FILE *fp;
        char board[80], dir[80], *ptr, flag[80];
        struct shortfile *x1;
        struct fileheader x;
        int i, start, total, my_t_lines=0, chart=0, showhead=0;
        init_all();
        strsncpy(board, getparm("board"), 32);
        my_t_lines=atoi(getparm("my_t_lines"));
        if(my_t_lines<10 || my_t_lines>40)
                my_t_lines=20;
        x1=getbcache(board);
        if(x1==0)
                http_fatal("错误的讨论区");
        strcpy(board, x1->filename);
        board_ban_ip(board);
        if (!canenterboard (currentuser.userid, board) && !HAS_PERM(PERM_SYSOP))
                http_fatal ("您已经被取消进入本板的权限");
        if(!has_read_perm(&currentuser, board) && !HAS_PERM(PERM_SYSOP))
                http_fatal("错误的讨论区");
        if(!has_BM_perm(&currentuser, board))
                http_fatal("您没有权限访问本页");

        modify_mode(u_info,READING);	//bluetent
        sprintf(dir, "boards/%s/.DIR", board);
        fp=fopen(dir, "r");
        if(fp==0)
                http_fatal("错误的讨论区目录");
        total=file_size(dir)/sizeof(struct fileheader);
        start=atoi(getparm("start"));
        if(strlen(getparm("start"))==0 || start>total-my_t_lines)
                start=total-my_t_lines;
        if(start<0)
                start=0;
        printf("<nobr><center>\n");
        strcpy(u_info->board, board);
        /*	printf("%s -- [讨论区: %s] 板主[%s] 文章数[%d]<hr color=green>\n",
        		BBSNAME, board, userid_str(x1->BM), total);
        	if(total<=0) http_fatal("本讨论区目前没有文章");
        	printf("<form name=form1 method=post action=bbsman>\n");
              	printf("<table width=613>\n");
              	printf("<tr><td>序号<td>管理<td>状态<td>作者<td>日期<td>标题\n");
        	fseek(fp, start*sizeof(struct fileheader), SEEK_SET);*/
        printf("<script language=JavaScript>\
               \
               function MM_jumpMenu(selObj){\
               eval(\"window.location='\"+selObj.options[selObj.selectedIndex].value+\"'\");\
       }\
               function SubmitFlag(flagmode){\
               document.form1.mode.value=flagmode;\
               document.form1.submit();\
       }\
       function selrange(x)\
       {if(event.shiftKey){var min=x;var max=document.getElementById('lastsel').value;if(min>max){var tmp=min;min=max;max=tmp;}var stt=document.getElementById('chk'+x).checked;for(var i=min;i<=max;i++)document.getElementById('chk'+i).checked=stt;}document.getElementById('lastsel').value=x;}\
               </script>\
Exemplo n.º 6
0
int main()
{
        char *board, buf[80], *board1, *title;
        int i, total=0;
        init_all();
        modify_mode(u_info,SELECT+20000);	//bluetent
        board=nohtml(getparm("board"));
        if(board[0]==0) {
                printf("%s -- 选择讨论区<hr color=green>\n", BBSNAME);
                printf("<form name=sel action=bbssel>\n");
                printf("讨论区名称: <input type=text name=board>");
                printf(" <input type=submit value=确定><br><br> 如果输入一部分板面名称,系统会为您自动选择");
                printf("</form><script language=javascript>sel.board.focus()</script>\n");
                http_quit();
        } else {
                for(i=0; i<MAXBOARD; i++) {
                        board1=shm_bcache->bcache[i].filename;
                        if(!has_read_perm(&currentuser, board1))
                                continue;
                        if(!strcasecmp(board, board1) && !(shm_bcache->bcache[i].flag & ZONE_FLAG)) {
                                sprintf(buf, "bbs%sdoc?board=%s", (currentuser.userdefine & DEF_THESIS)?"t":"", board1);
                                redirect(buf);
                                http_quit();
                        }
                }
                printf("%s -- 选择讨论区<hr color=green>\n", BBSNAME);
                //		printf("找不到这个讨论区, ", board);
                printf("标题中含有'%s'的讨论区有: <br><br>\n", board);
                printf("<table>");
                for(i=0; i<MAXBOARD; i++) {
                        board1=shm_bcache->bcache[i].filename;
                        title=shm_bcache->bcache[i].title;
                        if(!has_read_perm(&currentuser, board1))
                                continue;
                        if(!(shm_bcache->bcache[i].flag & ZONE_FLAG) && (strcasestr(board1, board) || strcasestr(title, board))) {
                                total++;
                                printf("<tr><td>%d", total);
                                printf("<td><a href=bbs%sdoc?board=%s>%s</a><td>%s<br>\n", (currentuser.userdefine & DEF_THESIS)?"t":"",
                                       board1, board1, title+7);
                                sprintf(buf, "bbs%sdoc?board=%s", (currentuser.userdefine & DEF_THESIS)?"t":"", board1);
                        }
                }
                if (total==1)
                        redirect(buf);
                printf("</table><br>\n");
                printf("共找到%d个符合条件的讨论区.\n", total);
        }
}
Exemplo n.º 7
0
int main()
{
        char word[80], buf[256];
        int type;
        int has=1;	//wzk
        init_all();
        modify_mode(u_info,DICT+20000);	//bluetent
        type=atoi(getparm("type"));
        strcpy(word, getparm("word"));
        printf("%s -- 字典查询<hr color=green>\n", BBSNAME);
        if(type==0 || word[0]==0) {
                printf("<form name=dict method=post action=bbsdict?type=1><pre>\n");
                hprintf("本字典 CDICT5.0 收录单词近 40000 , 一般较常见的单词和缩写均已收录,\n");
                printf("中英文输入均可, 支持'*'后缀通配符.\n\n");
                printf("请输入要查询的中英文单词: <input type=text name=word>\n");
                printf("<input type=submit>\n");
                printf("</pre></form><script language=javascript>dict.word.focus()</script>\n");
        } else {
                char file[80];
                FILE *fp;
                printf("查询单词: [%s]<br>\n", nohtml(word));
                sprintf(file, "tmp/%d.tmp", getpid());
                check(word);
                sprintf(buf, "bin/dict '%s' > %s", word, file);
                system(buf);
                fp=fopen(file, "r");
                if(fp==0)
                        http_fatal("内部错误");

                printf("<table width=610 border=0><tr><td><pre>\n");
                fgets(buf, 255, fp);		//wzk
                printf("<br>");			//wzk
                while(1) {
                        if(fgets(buf, 255, fp)==0) {
                                if (has)
                                        printf("单词\"%s\"没有找到", word);
                                break;
                        }
                        has=0;		//wzk
                        hprintf("%s", buf);
                }
                printf("</pre></table>");
                unlink(file);
        }
        check_msg();//bluetent 2002.10.31
        http_quit();
}
Exemplo n.º 8
0
int main()
{
        char user[32], title3[80], title[80], title2[80];
        int day;
        init_all();
        printf("<body background=%s bgproperties=fixed>",mytheme.bgpath);
        modify_mode(u_info,READING+20000);	//bluetent
        strsncpy(user, getparm("user"), 13);
        strsncpy(title, getparm("title"), 50);
        strsncpy(title2, getparm("title2"), 50);
        strsncpy(title3, getparm("title3"), 50);



        day=atoi(getparm("day"));
        if(day==0||(!strlen(user)&&!(strlen(title)))) {//huangxu@060406:禁止空查询
                //		printf("%s -- 站内文章查询<hr color=green>\n", BBSNAME);
                printf("<center><img src=/search_b.gif></center><hr color=green>");
                printf("<form name=bbsfind action=bbsfind>\n");
                printf("文章作者: <input maxlength=12 size=12 type=text name=user> (不填查找所有作者)<br>\n");
                printf("标题含有: <input maxlength=60 size=20 type=text name=title>");
                printf(" AND <input maxlength=60 size=20 type=text name=title2><br>\n");
                printf("标题不含: <input maxlength=60 size=20 type=text name=title3><br>\n");
                printf("查找最近: <input maxlength=5 size=5 type=text name=day value=7> 天以内的文章<br><br>\n");
				        if (HAS_PERM(PERM_SYSOP)||HAS_PERM(PERM_DENYPOST)&&HAS_PERM(PERM_OBOARDS))//huangxu@060406
				        {
				        	printf("<p><input type='radio' checked name='adminmode' value='0' />一般查找</p>");
        					printf("<p><input type='radio' name='adminmode' value='1' />查找文章以便删除</p>");
        					printf("<p><input type='radio' name='adminmode' value='2' />查找回收站</p>");
        				}
                printf("<input type=submit value=提交查询></form><script language=javascript>bbsfind.user.focus()</script>\n");
        } else {
                search(user, title, title2, title3, day*86400);
        }
        printf("</body>");
        http_quit();
}
Exemplo n.º 9
0
int main()
{
        int i;
        init_all();
        modify_mode(u_info,FRIEND+20000);	//bluetent
        if(!loginok)
                http_fatal("дЗипн╢╣гб╪, гКох╣гб╪");
        loadfriend(currentuser.userid);
        printf("<center>\n");
        printf("%s -- ╨цсяцШ╣╔ [й╧сцуъ: %s]<hr color=green><br>\n", BBSNAME, currentuser.userid);
        printf("дЗ╧╡иХ╤╗ак %d н╩╨цся<br>", friendnum);
        printf("<table border=1><tr><td>пР╨е<td>╨цся╢З╨е<td>╨цсяк╣цВ<td>и╬ЁЩ╨цся");
        for(i=0; i<friendnum; i++) {
                printf("<tr><td>%d", i+1);
                printf("<td><a href=bbsqry?userid=%s>%s</a>", fff[i].id, fff[i].id);
                printf("<td>%s\n", nohtml(fff[i].exp));
                printf("<td>[<a onclick='return confirm(\"х╥й╣и╬ЁЩбП?\")' href=bbsfdel?userid=%s>и╬ЁЩ</a>]", fff[i].id);
        }
        printf("</table><hr color=green>\n");
        printf("[<a href=bbsfadd>лМ╪спб╣д╨цся</a>]</center>\n");
        //	for(i=0;i<friendnum2;i++)
        //		printf("%d ", u_info->friend[i]);
        http_quit();
}
Exemplo n.º 10
0
int main()
{
    FILE *fp;
    char userid[80], buf[512], board[80], dir[80], file[512], filename[80];
    char ch, tmp[80], *ptr;
    struct fileheader x;
    int i, found=0;
    init_all();
    strsncpy(board, getparm("board"), 32);
    strsncpy(file, getparm("file"), 32);
    //printf("<head>我爱南开站-Telnet样式</head>");
    printf("<script language='javascript' src='/js/telnetview.js'></script>");//Js支持
    printf("<body bgproperties=fixed>",mytheme.bgpath);
    if (*file!='/') //帖子
    {
        modify_mode(u_info,READING);	//bluetent
        start=atoi(getparm("num"));
        if(!has_read_perm(&currentuser, board) && !HAS_PERM(PERM_SYSOP))
            http_fatal("错误的讨论区");
        if (!canenterboard (currentuser.userid, board) && !HAS_PERM(PERM_SYSOP))
            http_fatal ("您已经被取消进入本板的权限");
        strcpy(board, getbcache(board)->filename);
        if(loginok)
            brc_init(currentuser.userid, board);
        sprintf(dir, "boards/%s/.DIR", board);
        total=file_size(dir)/sizeof(struct fileheader);
        if(start>=total)
            start=total-1;
        if(start<0)
            start=0;
        fp=fopen(dir, "r+");
        if(fp==0)
            http_fatal("目录错误");
        if(start==0) {
            while(1) {
                if(fread(&x, sizeof(x), 1, fp)<=0) {
                    printf("文章不存在!");
                    break;
                }
                if(!strcmp(x.filename, file)) {
                    show_file(board,&x);
                    break;
                }
            }
            fcloseall();
            return 0;
        }

        fseek(fp,sizeof(struct fileheader)*start,SEEK_SET);
        if(fread(&x, sizeof(x), 1, fp)<=0)
            http_fatal("读取错误.");
        show_file(board,&x);
        fcloseall();
        return 0;
    }//帖子结束
    else {//精华区
        FILE *fp;
        modify_mode(u_info,DIGEST+20000);	//bluetent
        strsncpy(file, getparm("file"), 511);
        if(strstr(file, ".Search") || strstr(file, ".Names")|| strstr(file, "..")|| strstr(file, "SYSHome"))
            http_fatal("错误的文件名");
        sprintf(buf, "0Announce%s", file);
        fp=fopen(buf, "r");
        if(fp==0)
            http_fatal("错误的文件名");
        printf("<table><tr><td id=\"c\" bgcolor=\"black\" style=\"font-size:16px;line-height:1\"></td></tr></table>");
        printf("<script language=\"javascript\">\n\r	init();\n\r");
        printf("document.getElementById('c').innerHTML=previewthis('");

        while(1) {
            if(fgets(buf, 256, fp)==0)
                break;
            jsprint(void1(buf));
        }
        printf("');\n\r</script>");
        fclose(fp);
        //check_msg();//bluetent 2002.10.31
    }

    http_quit();
}
Exemplo n.º 11
0
int main()
{
        FILE *fp;
        int type=0, i, num, l;
        char userid[80], buf[512], path[512], file[512], board[512], title[80]="";
        //struct shortfile *brd;
        struct fileheader  *x;
        char c;//huangxu@060331
        init_all();
        modify_mode(u_info,EDIT+20000);	//bluetent
        if(!loginok)
                http_fatal("匆匆过客不能修改文章,请先登录");
        strsncpy(board, getparm("board"), 20);
        type=atoi(getparm("type"));
        brd=getbcache(board);
        if(brd==0)
                http_fatal("错误的讨论区!");
        strcpy(board, brd->filename);
        strsncpy(file, getparm("file"), 20);
        if(!has_post_perm(&currentuser, board))
                http_fatal("错误的讨论区或者您无权在此讨论区发表文章");
        x=get_file_ent(board, file);
        if(strstr(file, "..") || strstr(file, "/"))
                http_fatal("错误的参数");
        if(x==0)
                http_fatal("错误的参数");
        if(strcmp(x->owner, currentuser.userid))
                if(!has_BM_perm(&currentuser, board))
                        http_fatal("你无权修改此文章");

        printf("<center>%s -- 修改文章 [使用者: %s]<hr color=green>\n", BBSNAME, currentuser.userid);
        if(type!=0)
                return update_form(board, file);
        printf("<table border=1>\n");
        printf("<tr><td>");
        printf("<tr><td><form method=post action=bbsedit>\n");
        hsprintf(buf, "%s", x->title);
        printf("使用标题: %s 讨论区: %s<br>\n", buf, board);
        printf("本文作者:%s<br>\n", currentuser.userid);
        sprintf(path, "boards/%s/%s", board, file);
        fp=fopen(path, "r");
        if(fp==0)
                http_fatal("文件丢失");
        fseek(fp,0,2);
        l=ftell(fp);
        fseek(fp,0,0);
        for (i=4;l>0&&i>0;l--)//huangxu@060331
        {
        	c=fgetc(fp);
       		if (c==0x0a)
        		i--;
        }
        if (l<=0)  http_fatal("错误的文件");

        printf("<textarea name=text rows=20 cols=80 wrap=physicle>");
        while(1) {
                if(fgets(buf, 500, fp)==0)
                        break;
                        //为什么这些代码无法工作?
                /*for (;i>0;i--)
                {
                	printf("CHAR::%d::",*(buf+44));
                	pbuf++;
                	pbuf=strchr(pbuf,0x0a);
                	if (!pbuf) 
                	{
                		printf("NOTFOUND%d",i);
                		break;
                		}
                		printf("FOUND:%d,Length:%d,str=%s::",pbuf-buf,strlen(buf),buf);
                }*/
                if(!strcasestr(buf, "</textarea>"))
                        printf("%s", buf);
        }
        fclose(fp);
        printf("</textarea>\n");
        printf("<tr><td class=post align=center>\n");
        printf("<input type=hidden name=type value=1>\n");
        printf("<input type=hidden name=board value=%s>\n", board);
        printf("<input type=hidden name=file value=%s>\n", file);
        printf("<input type=submit value=存盘> \n");
        printf("<input type=button value=放弃编辑 onclick=javascript:history.go(-1)></form>\n");
        printf("</table>");
        http_quit();
}
Exemplo n.º 12
0
int main()
{
        FILE *fp;
        char  log[STRLEN],id[14];

        init_all();

        modify_mode(u_info,DIGEST+20000);	//bluetent
        printf("<script language=JavaScript src=/scrolldown.js></script>");
        printf("<body background=%s bgproperties=fixed>",mytheme.bgpath);
        strsncpy(id, getparm("id"), 13);
        char *id2=trim(id);
        if(strcmp("",id2)) {//属于查找文集的
                struct userec *x;
                x=getuser(id2);
                if(x==0) {
                        showinfo("该id不存在");
                        return 1;
                }
                char buf[256];
                sprintf(buf,"0Announce/PersonalCorpus/%c/%s/.Names",toupper(x->userid[0]),x->userid);
                FILE *fp=fopen(buf,"r");
                if(fp==0) {
                        sprintf(buf,"%s尚未创建个人文集,<a href=bbspstmail?userid=%s&title=快去建个人文集吧!>发信让其快建啦</a>",x->userid,x->userid);
                        showinfo(buf);
                        return 1;
                }
                sprintf(buf,"bbs0an?path=/PersonalCorpus/%c/%s",toupper(x->userid[0]),x->userid);
                redirect(buf);
                return 0;
        }
        /*thunder 个人文集*/
        printf("<font size=3><center>%s个人文集库</center></font><br><hr>",BBSNAME);
        printf("展示自我,搭建属于自己的温馨网上家园,本站个人文集库为您提供无限动力!");
        if((currentuser.userlevel & PERM_LOGINOK) && !(currentuser.userlevel&PERM_PERSONAL))
                printf("<a href=createpc>创建我的文集</a><br>");
        printf("<br>如何建设,管理,宣传自己的文集,欢迎访问<a href=bbsdoc?board=PersonalCorpus>个人文集经验交流区</a>");
        printf("<center>");
        int i=0,j,c=0,a[]={10,16};
        for(i=0;i<2;i++) {
                printf("<br>");
                for(j=0;j<a[i];j++,c++)
                        printf("<a href=bbs0an?path=/PersonalCorpus/%c>  --%c-- </a> ",'A'+c,'A'+c);
        }
        printf("	<form action=bbspc  method=post>\
               查找<input  style='height:20px; border:1px solid #404040' type=text name=id maxlength=13 size=13 onmousemove='this.focus()'>的个人文集.</form>\
               </center>\
               ");

if (0 && HAS_PERM(PERM_POST))
{
 printf("<p><center><a href=bbsdoc?board=PersonalCorpus>精彩文集</a></center></p>");
 printf("<p style=\"text-align:center\">用下载包恢复文集</p>");
 printf("<p><center><iframe border=\" 0\"  scrolling=\" no\"  style=\" border:none; height:40px; width:500px; margin: 0px auto\"  src=\" bbsupload?board=*restorepc\" ></iframe></center></p>");
}
 /*        char buf[PATHLEN];
        char tmpfile[STRLEN];
        int index=1;
        fp=fopen("0Announce/PersonalCorpus/pctop","r");
        if(fp!=NULL) {
                fgets(buf, 128, fp);
                printf("访问量排行TOP50(访问量:人次),截至日期:%s<table><tr>",buf);
                int count=0;
                char pctitle[STRLEN];

                for(i=0;i<3;i++) {
                        printf("<td valign=top>");
                        for(j=0;j<20;j++) {
                                if(fgets(buf, 128, fp)==0)
                                        goto E;
                                sscanf(buf,"%d %s",&count,id);
                                getpctitle (id, pctitle);
                                printf("%2d&nbsp;&nbsp;<a href=bbs0an?path=/PersonalCorpus/%c/%s>%s</a> %s<font color=green>%d</font><br>",index,toupper(id[0]),id,pctitle,id,count);

                                index++;
                        }
                        printf("</td>");
                }
        }

E:
        if(j!=20)
                printf("</td>");
        printf("</tr></table>");

        sprintf(tmpfile,"tmp/%d.pc",getpid());
        sprintf(buf, "wc -l 0Announce/PersonalCorpus/Log > %s" ,tmpfile);
        system(buf);
        fp=fopen(tmpfile, "r");
        if(fp==0) {
                showinfo("个人文集创建日志不存在");
                return 1;
        }
        i=0;



        fscanf(fp," %d ",&i);

        printf("<br>本站现有文集用户总数:%d,最新建立文集的50位网友如下",i);
        fclose(fp);
        sprintf(buf, " tail -n 50  0Announce/PersonalCorpus/Log | tac > %s" ,tmpfile);
        system(buf);
        fp=fopen(tmpfile, "r");
        if(fp==0) {
                showinfo("个人文集创建日志不存在");
                return 1;
        }

        char user[14],date[14],name[40];
        index=0;
        printf("<table cellspacing=1 cellpadding=2  width=90% border=0 >\n");
        printf("<tr bgcolor=%s class=title>
               <td align=middle width=30>序号</td>
               <td align=middle width=*>文集名称</td>
               <td align=middle>作者</td>
               <td align=middle >创建日期</td>
               </tr>",mytheme.bar);
        while(1) {
                if(fgets(buf, 128, fp)==0)
                        break;
                sscanf(buf,"%s %s %s ",user, date,name);

                index++;

                printf("<tr>
                       <td align=middle width=30>%d</td>
                       <td><a href=bbs0an?path=/PersonalCorpus/%c/%s> %s</a></td>
                       <td align=middle><a href=bbsqry?userid=%s>%s</a></td>
                       <td align=middle>%s</td>
                       </tr>",index,toupper(user[0]),user,name,user,user,date);
                if(index==100)
                        break;
        }
        printf("</table>");
        fclose(fp);
        unlink(tmpfile);
        printf("<br>注:只显示最新建立50位网友的个人文集.");
*/
}
Exemplo n.º 13
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();
}
Exemplo n.º 14
0
int bbsvote_act(char * info)
{
	FILE *fp;
	struct votebal currvote, ent;
	char buf[STRLEN], buf1[512];
	char buf2[1024];
	struct ballot uservote;
	//	struct votelog log;
	int aborted = NA, pos;
	int i, chkd;
	unsigned int j, multiroll = 0;
	char board[80];
	char posturl[256];
	char controlfile[STRLEN];
	char *date, *tmp1, *tmp2;
	char flagname[STRLEN];
	char logname[STRLEN];
	int voted_flag;		//用户是否投过该项票
	int num_voted;		//这个是有多少人投过票
	int num_of_vote;	//这个是开启的投票数
	int votenum;		//这个是用户选择进行第几个投票
	int votevalue = 0;
	int procvote;
	time_t closedate;
	struct stat st;
	int now_t=time(0);
	if (!loginok) 
	{
		strcpy(info, "匆匆过客不能投票。");
		return -1;
	}
	strsncpy(board, getparm("B"), 32);
	if (!*board)
	{
		strsncpy(board, getparm("board"), 32);
	}
	votenum = atoi(getparm("votenum"));
	procvote = atoi(getparm("procvote"));
	modify_mode(u_info, VOTING);
	if(!has_post_perm(&currentuser, board) || !HAS_PERM(PERM_VOTE))//去死吧倒霉的全站投票
	{
		strcpy(info, "您无权在本板内投票。");
		return -1;
	}
	sprintf(controlfile, "vote/%s/%s", board, "control");
	num_of_vote = (stat(controlfile, &st) == -1) ? 0 : st.st_size / sizeof (struct votebal);
	if (!num_of_vote)
	{
		strcpy(info, "抱歉, 目前并没有任何投票举行。");
		return -2;
	}
	fp = fopen(controlfile, "r");
	if (!fp)//大概不会发生
	{
		strcpy(info, "系统错误。");
		return -256;
	}
	//从if中提出来的
	if (!votenum) //这是投票列表
	{
		printf ("<card title=\"投票箱 -- %s\">", BBSNAME);
		printf ("<p><anchor><go href=\"bbsdoc.wml?board=%s\" />%s板</anchor>投票</p>", board, board);
		for (i = 1; i <= num_of_vote; i++) 
		{
			fread(&ent, sizeof (struct votebal), 1, fp);
			sprintf(flagname, "vote/%s/flag.%d", board, (int) ent.opendate);
			num_voted = (stat(flagname, &st) ==	-1) ? 0 : st.st_size / sizeof (struct ballot);
			closedate = ent.opendate + ent.maxdays * 86400;
			//注意,这里的date成了结束时间
			w_hsprintf(buf2, "%s", ent.title);//输出标题
			printf("<p><anchor><go href=\"bbsvote.wml?board=%s&amp;votenum=%d\" />#%d %s<br />", board, i, i, buf2);
			//发起投票者被华丽地无视了!
			datestr(buf2, closedate);
			//类别也被华丽地无视了!
			printf ("结束:%s 参与:%d</anchor></p>", buf2, num_voted);
		}
		fclose(fp);
		return 0;
	}
	else 
	{
		if (votenum > num_of_vote)
		{
			strcpy(info, "参数错误。");
			return -3;
		}
		fseek(fp, sizeof (struct votebal) * (votenum - 1), 0);
		fread(&currvote, sizeof (struct votebal), 1, fp);
		fclose(fp);
		sprintf(flagname, "vote/%s/flag.%d", board, (int) currvote.opendate);
		num_voted = (stat(flagname, &st) == -1) ? 0 : st.st_size / sizeof (struct ballot);
		pos = 0;
		fp = fopen(flagname, "r");
		voted_flag = NA;
		if (fp) 
		{
			for (i = 1; i <= num_voted; i++) 
			{
				fread(&uservote, sizeof (struct ballot), 1, fp);
				if (!strcasecmp(uservote.uid, currentuser.userid)) 
				{
					voted_flag = YEA;
					pos = i;
					break;
				}
			}
			fclose(fp);
		}
		if (!voted_flag)
		{
			memset(&uservote, 0, sizeof (uservote));
		}
		if (procvote == 0) 
			//-------投票权限判断
			//没仔细看-_-b
		{
			if (currentuser.firstlogin > currvote.opendate)	
			{
				strcpy(info, "对不起, 本投票在您帐号申请之前开启,您不能投票。");
				return -3;
			}
			else if (!HAS_PERM(currvote.level & ~(LISTMASK | VOTEMASK)))
			{
				strcpy(info, "对不起,您目前尚无权在本票箱投票。");
				return -4;
			}
			else if(currvote.level & LISTMASK )
			{
				char listfilename[STRLEN];
				setvfile(listfilename, board, "vote.list");
				if(!dashf(listfilename)) 
				{
					strcpy(info, "对不起,本票箱需要设定好投票名册方可进行投票。");
					return -5;
				}
				else if(!seek_in_file(listfilename,currentuser.userid))
				{
					strcpy(info, "对不起, 投票名册上找不到您的大名。");
					return -6;
				}
			}
			else if(currvote.level & VOTEMASK )
			{
				if(currentuser.numlogins < currvote.x_logins || currentuser.numposts < currvote.x_posts ||currentuser.stay < currvote.x_stay * 3600
					|| currentuser.firstlogin > currvote.opendate - currvote.x_live * 86400)
				{
					strcpy(info, "对不起,您目前尚不够资格在本票箱投票。");
					return -7;
				}
			}
			closedate =	currvote.opendate + currvote.maxdays * 86400;
			printf ("<card title=\"投票箱 -- %s\">", BBSNAME);
			w_hsprintf (buf2, "%s", currvote.title);
			printf("<p>投票主题: %s<br />", buf2);
			printf("投票类型: %s<br />", vote_type[currvote.type - 1]);
			printf("发起投票: <anchor><go href=\"bbsqry.wml?userid=%s\" />%s</anchor><br />", currvote.userid, currvote.userid);
			printf("所在板面: <anchor><go href=\"bbsdoc.wml?board=%s\" />%s</anchor><br />", board, board);
			datetime(buf2, closedate);
			printf("结束时间: %s<br />", buf2);
			if (currvote.type != VOTE_ASKING)
			{
				printf("最多投票: %d<br />", currvote.maxtkt);
				printf("投票说明:<br />");
				sprintf(buf, "vote/%s/desc.%d", board, (int) currvote.opendate);
				fp = fopen(buf, "r");
				if (fp)
				{
					while (1) 
					{
						if (fgets(buf1, sizeof (buf1), fp) == 0)
						{
							break;
						}
						w_hprintf("%s", buf1);
						printf ("<br />");
					}
					fclose(fp);
				}
			}
			printf ("</p>");
			//multiroll这种东西没用啦
			sprintf (posturl, "bbsvote.wml?board=%s&amp;votenum=%d", board, votenum);
			switch (currvote.type) 
			{
				case VOTE_SINGLE:
					//单选
					j =	uservote.voted + (uservote.voted << currvote.totalitems);
					chkd = 0;
					//这是当前选中的
					printf ("<p>选项列表:<br />");
					for (i = 0; i < currvote.totalitems; i++) 
					{
						w_hprintf ("选项%d %s", i + 1, currvote.items[i]);
						printf ("<br />");
						if (j & 1)
						{
							chkd = i + 1;
						}
						j >>= 1;
					}
					printf ("请选择:<select name=\"inp_vote\" value=\"%d\">", chkd);
					printf ("<option value=\"0\">未选择</option>");
					for (i = 0; i < currvote.totalitems; i++)
					{
						printf ("<option value=\"%d\">%d</option>", i + 1, i + 1);
					}
					printf ("</select></p>");
					votesug_inp(&uservote);
					printf ("<p><anchor><go href=\"%s\" method=\"post\"><postfield name=\"procvote\" value=\"2\" />", posturl);
					wmlPostfield("vote");
					votesug_pst();
					printf ("</go>投票</anchor></p>");
					break;
				case VOTE_MULTI:
					//复选
					j = uservote.voted + (uservote.voted << currvote.totalitems);
					printf ("<p>选项列表<em>(最多投%d票)</em>:<br />", currvote.maxtkt);
					for (i = 0; i < currvote.totalitems; i++) 
					{
						printf ("<select name=\"inp_votemulti%d\" value=\"%d\"><option value=\"0\">不选择</option><option value=\"1\">已选择</option></select> ", i + 1, (j & 1));
						w_hprintf ("%s", currvote.items[i]);
						printf ("<br />");
						j >>= 1;
					}
					printf ("</p>");
					votesug_inp(&uservote);
					printf ("<p><anchor><go href=\"%s\" method=\"post\"><postfield name=\"procvote\" value=\"3\" />", posturl);
					for (i = 0; i < currvote.totalitems; i++)
					{
						sprintf (buf2, "votemulti%d", i + 1);
						wmlPostfield(buf2);
					}
					votesug_pst();
					printf ("</go>投票</anchor></p>");
					break;
				case VOTE_YN:
					//是非 ... 不是跟单选一样的么?
					j =	uservote.voted + (uservote.voted << currvote.totalitems);
					chkd = 0;
					//这是当前选中的
					printf ("<p>选项列表:<br />");
					for (i = 0; i < currvote.totalitems; i++) 
					{
						if (j & 1)
						{
							chkd = i + 1;
							break;
						}
						j >>= 1;
					}
					printf ("请选择:<select name=\"inp_vote\" value=\"%d\">", chkd);
					printf ("<option value=\"0\">未选择</option>");
					for (i = 0; i < currvote.totalitems; i++)
					{
						printf ("<option value=\"%d\">", i + 1);
						w_hprintf ("%s", currvote.items[i]);
						printf ("</option>");
					}
					printf ("</select></p>");
					votesug_inp(&uservote);
					printf ("<p><anchor><go href=\"%s\" method=\"post\"><postfield name=\"procvote\" value=\"1\" />", posturl);
					//这里不同,单选procvote=2
					wmlPostfield("vote");
					votesug_pst();
					printf ("</go>投票</anchor></p>");
					break;
				case VOTE_VALUE:
					//数值
					printf ("<p>请输入一个值:");
					printf ("<input name=\"inp_votevalue\" value=\"%d\" /></p>", uservote.voted);
					votesug_inp(&uservote);
					printf ("<p><anchor><go href=\"%s\" method=\"post\"><postfield name=\"procvote\" value=\"4\" />", posturl);
					wmlPostfield("votevalue");
					votesug_pst();
					printf ("</go>投票</anchor></p>");
					break;
				case VOTE_ASKING:
					votesug_inp(&uservote);
					printf ("<p><anchor><go href=\"%s\" method=\"post\"><postfield name=\"procvote\" value=\"5\" />", posturl);
					votesug_pst();
					printf ("</go>投票</anchor></p>");
					break;
				default:
					printf ("<p>没有这种类型的投票啊。</p>");
					return 0;
					//:(
				//<-switch
			}
		}
		else
		{
			if (procvote != currvote.type)
			{
				strcpy(info, "投票错误。");
				return -1;
			}
			switch (procvote) 
			{
				case 2:	//VOTE_SINGLE
					votevalue = 1;
					votevalue <<= atoi(getparm("vote")) - 1;
					if (atoi(getparm("vote")) > currvote.totalitems + 1)
					{
						strcpy(info, "无效选项。");
						return -1;
					}
					aborted = (votevalue == uservote.voted);
					break;
				case 3:	//VOTE_MULTI
					votevalue = 0;
					j = 0;
					for (i = currvote.totalitems - 1; i >= 0; i--) 
					{
						votevalue <<= 1;
						sprintf(buf, "votemulti%d", i + 1);
						votevalue |= !!atoi(getparm(buf));
						j += !!atoi(getparm(buf));
					}
					aborted = (votevalue == uservote.voted);
					if (j > currvote.maxtkt) 
					{
						sprintf(info, "本投票最多只能选择%d个选项。", currvote.maxtkt);
						return -1;
					}
					break;
				case 1:	//VOTE_YN
					votevalue = 1;
					j = atoi(getparm("vote")) - 1;
					if (j >	currvote.totalitems || j < 0)
					{
						strcpy(info, "无效选项。");
						return -1;
					}
					votevalue <<= j;
					aborted = (votevalue == uservote.voted);
					break;
				case 4:	//VOTE_VALUE
					aborted = ((votevalue = atoi(getparm("votevalue"))) == uservote.voted);
					if (votevalue < 0 || votevalue > currvote.maxtkt) 
					{
						sprintf(info, "应当介于0到%d之间(含)。", currvote.maxtkt);
						return -1;
					}
					break;
				case 5: //VOTE_ASKING
					aborted = NA;
					break;
				//<-switch
			}
			printf ("<card title=\"投票箱 -- %s\">", BBSNAME);
			if (aborted == YEA) 
			{
				printf ("<p>未修改该投票的选项。</p>");
				return 0;
			}
			else
			{
				fp = fopen(flagname, "r+");
				if (fp == 0)
				{
					fp = fopen(flagname, "w+");
				}
				if (fp)
				{
					flock(fileno(fp), LOCK_EX);
					if (pos > 0)
					{
						fseek(fp, (pos - 1) * sizeof (struct ballot), SEEK_SET);
					}
					else
					{
						fseek(fp, 0, SEEK_END);
					}
					strcpy(uservote.uid, currentuser.userid);
					uservote.voted = votevalue;
					for (i = 0; i < 3; i++)
					{
						sprintf (buf2, "sug%d", i);
						strncpy (uservote.msg[i], getparm(buf2), 78);
						removeInvisibleChars(uservote.msg[i], ' ');
					}
					fwrite(&uservote, sizeof (struct ballot), 1, fp);
					flock(fileno(fp), LOCK_UN);
					fclose(fp);
					printf("<p>已经帮您投入票箱中。</p>");
					sprintf(buf, "%s %s %s", currentuser.userid, currentuser.lasthost, Ctime(now_t));
					fs_append(BBSHOME"/vote.log", buf);
				}
				else
				{
					printf ("<p>系统发生了一点小小的问题-_-b</p>");
				}
			}
		}
	}