NJUWeb 0.9下通过
/* 邮编区号查询程序, by mok.bbs@smth.org */
#include "BBSLIB.inc"
#include <netdb.h>
#include <netinet/in.h>
#define MAXLEN 22
int main(){
int type;
char content[50];
init_all();
printf("%s -- 邮编区号查询 <hr color=green>",BBSNAME);
type=atoi(getparm("type"));
strsncpy(content,getparm("content"),50);
if (type==0||(strlen(content)>MAXLEN)) {
printf("<br><center>欢迎您使用本站的邮编区号查询\n");
printf("<br>如有建议欢迎在<a href='bbsdoc?board=sysop'>sysop</a>版提出
</center><br>");
if (strlen(content)>MAXLEN) { printf("您的输入太长了,请重新查询
<br>");}
printf("<form action='/cgi-bin/bbs/bbsybqh?type=1' name=queryform
method=POST >\n");
printf("您要查询的内容:<input type=test name=content
maxlength=20>\n");
printf("<input type=submit value=\"提交查询内容\"
onclick=\"if(document.queryform.content.value=='') {alert(\'请输入您要查
询的内容!\');return false;}\"> \n");
printf("</form>");
http_quit();
}
else{
printf("查询\"<font color=red>%s</font>\"结果如下:<br><br>\n",
content);
result(content);
http_quit();
}
}
int result(char content[])
{
FILE *fp;
int i,j,count=0;
char buf[512], buf2[80];
char diqu[30],shengfen[20],youbian[10],quhao[15],all[100];
fp=fopen("/home/bbs/etc/ybqh.txt","r");
if (fp==0) { printf("打开数据文件出错! 如有疑问请到<a
href='bbsdoc?board=sysop'>sysop</a>发文\n"); return ; }
while(1){
buf[0]=0;
if(fgets(buf, 500, fp)<=0) break;
if(strlen(buf)<10) continue;
sscanf(buf,"%s%s%s%s",diqu,shengfen,youbian,quhao,buf2);
if (strstr(diqu,content)||strstr(shengfen,content)||strstr(youbian,
content)||strstr(quhao,content)){
if (count==0) {
printf("<center><table width=510 border=0 cellspacing=0
cellpadding=0>\n");
printf("<tr><td><font color=red>地区</font></td><td><font color=red>
省份</font></td><td><font color=red>邮编</font></td><td><font
color=red>区号</font></td></tr>\n");
}
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
diqu,shengfen,youbian,quhao);
count++;
}
}
printf("\n</table></center>");
fclose(fp);
if (count==0) {
printf("\n<br>唉呀,没有找到符合条件的结果:<a href=# onclick='history.
go(-1)'>返回重查</a>  <a href='bbsdoc?board=sysop'>报告站长
</a>");
}
else{
printf("<br><br><br>共为您找到%d条记录<br>\n",count);
}
printf("<br><br>欢迎使用本查询系统。如果发现错误之处或有改进意见,请在
<a href='bbsdoc?board=sysop'>sysop</a>版发文。\n");
}
--
修改:mOk FROM 202.198.16.92
FROM 202.198.16.92