From 882668d28c12d3e21d0441045d108feb9647c3c3 Mon Sep 17 00:00:00 2001 From: ptt Date: Mon, 14 Apr 2003 18:27:08 +0000 Subject: *** empty log message *** git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@793 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- web/l | 2 +- web/mod_ptt.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 126 insertions(+), 31 deletions(-) (limited to 'web') diff --git a/web/l b/web/l index 2ceb6767..5feafa93 100755 --- a/web/l +++ b/web/l @@ -1 +1 @@ -lynx -dump ptt.cc/test.ptt +lynx -dump ptt.cc/menu diff --git a/web/mod_ptt.c b/web/mod_ptt.c index ecb77117..d5606e9f 100644 --- a/web/mod_ptt.c +++ b/web/mod_ptt.c @@ -42,48 +42,143 @@ static void setup_module_cells() } - -static int ptt_handler(request_rec *r) +static int xml_header(request_rec *r) +{ + r->content_type = "text/xml"; + ap_send_http_header(r); + ap_rputs(" \n", r); + ap_rprintf(r, "", SHM->max_user ); +} +static int showboard(request_rec *r, int id) { int i; - excfg *dcfg; - + boardheader_t *bptr=NULL; + id=id-1; + ap_rprintf(r,""); + bptr = (boardheader_t *)bcache[id].firstchild[0]; + for(; bptr!= (boardheader_t*)~0; ) + { + if((bcache[id].brdattr&BRD_HIDE)|| + bcache[id].level&& !(bcache[id].brdattr & BRD_POSTMASK )) continue; + ap_rprintf(r,"\n"); + i=(bptr-bcache); + ap_rprintf(r," %d",i+1); + ap_rprintf(r," %s\n",bptr->brdname); + ap_rprintf(r," %s\n",ap_escape_html(r->pool,bptr->title)); + ap_rprintf(r," %d\n",bptr->nuser); + ap_rprintf(r," %d\n",bptr->gid); + ap_rprintf(r," %d\n",bptr->childcount); + ap_rprintf(r," %s\n",bptr->BM); + ap_rprintf(r," %d\n",bptr->brdattr); + ap_rprintf(r," %d\n",SHM->total[i]); + ap_rprintf(r,"\n"); + bptr=(boardheader_t*)bptr->next[0]; + } + + ap_rprintf(r,""); +} - dcfg = our_dconfig(r); - r->content_type = "text/html"; - ap_soft_timeout("send ptt call trace", r); +static int showpost(request_rec *r,int bid,int id, int num) +{ + int i; + num=256; + id=1; + char path[512]; + fileheader_t headers[256]; + memset(headers,0, sizeof(fileheader_t)*256); + sprintf(path,BBSHOME"/boards/%c/%s/.DIR", + bcache[bid-1].brdname[0],bcache[bid-1].brdname); + get_records(path, headers, sizeof(fileheader_t)*256, id,num); + + ap_rprintf(r,""); + + for(i=0;i<256;i++) + { + ap_rprintf(r,"\n"); + ap_rprintf(r," %d",i+1); + ap_rprintf(r," %s\n",headers[i].filename); + ap_rprintf(r," %s\n",headers[i].owner); + ap_rprintf(r," %s\n",headers[i].date); + ap_rprintf(r," %s\n", + ap_escape_html(r->pool,headers[i].title)); + ap_rprintf(r," %d\n",headers[i].money); + ap_rprintf(r," %c\n",headers[i].filemode); + ap_rprintf(r," %d\n",headers[i].recommend); + ap_rprintf(r,"\n"); + } + ap_rprintf(r,""); +} +static int showmenujs(request_rec *r) +{ + int i; + boardheader_t *bptr; + r->content_type = "text/text"; ap_send_http_header(r); + ap_rputs("d=new dTree('d');\n",r); + ap_rputs("d.add(0,-1,'Class','');\n",r); + for(i=1;i<=numboards;i++) + { + bptr=&bcache[i-1]; + if(!isalpha(bptr->brdname[0]))continue; + + ap_rprintf(r,"d.add(%d,%d,\"%s %s..\",'/boards?%s');\n", + i,bptr->gid-1, + bptr->gid==1?"":bptr->brdname, + ap_escape_quotes(r->pool, + ap_escape_html(r->pool,bptr->title+7)),i); + } + ap_rputs("d.draw()\n",r); + return OK; +} +static int showxml(request_rec *r) +{ + int bid=1; + xml_header(r); if (r->header_only) { ap_kill_timeout(r); return OK; } + if(r->args) bid=atoi(r->args); + if(bid<1 || bid>numboards)bid=1; + + if( + !(bcache[bid-1].brdattr&BRD_HIDE)&& + !(bcache[bid-1].level&&!(bcache[bid-1].brdattr & BRD_POSTMASK))) + if( bid==1||bcache[bid-1].brdattr&BRD_GROUPBOARD) + showboard(r,bid); + else + showpost(r,bid,0,0); + return OK; +} +static int ptt_handler(request_rec *r) +{ + excfg *dcfg; - ap_rputs(" ptt3

\n", r); + dcfg = our_dconfig(r); + + ap_soft_timeout("send ptt call trace", r); + + if(!strncmp(r->unparsed_uri,"/menu",5)) + showmenujs(r); + else + showxml(r); - ap_rprintf(r, " Apache HTTP Server version: \"%s\"\n", - ap_get_server_version()); - ap_rprintf(r,"r->filename : %s
",r->filename); - ap_rprintf(r,"r->request_time : %s
",ctime(&r->request_time)); - ap_rprintf(r,"r->method : %s
",r->method); - ap_rprintf(r,"r->method_number : %d
",r->method_number); - ap_rprintf(r,"r->path_info : %s
",r->path_info); - ap_rprintf(r,"r->args : %s
",r->args); - ap_rprintf(r,"r->unparsed_uri : %s
",r->unparsed_uri); - ap_rprintf(r,"r->handler : %s
",r->handler); - ap_rprintf(r,"r->content_type : %s
",r->content_type); - - - ap_rprintf(r, " Server built: \"%s\"
", ap_get_server_built()); - ap_rprintf(r, " numboards: \"%d\"
", numboards); - ap_rprintf(r, " shm: \"%d\"
", SHM->loaded ); - ap_rprintf(r, " max_user:%d
", SHM->max_user ); - for(i = 0; i < 10; i++) - ap_rprintf(r,"%d. %s %s
",i,bcache[i].brdname,bcache[i].title); - - // for(i = 0; i < 10 /*numboards*/; i++) - // ap_rprintf(r,"%s %s
",bcache[i].brdname,bcache[i].title); ap_kill_timeout(r); return OK; } -- cgit v1.2.3