|
珞珈山水BBS →
电脑网络 →
BBS安装与维护 →
单文区文章阅读
|
| 单文区文章阅读 [返回] |
|---|
|
发信人: mOk@bbs.nju.edu.cn, 信区: BBSDev 标 题: NjuWebBBS 0.9 超连接判断的一点改进 发信站: 南京大学小百合站 (Sun Mar 16 15:30:01 2003) 转信站: WHU!news.tiaozhan.com!news.zixia.net!NJU 出 处: bbs.nju.edu.cn 原理:对于http:// ftp:// 出现第一个特殊字符前应该有3个 '/' 修改后对: http://www.jlu.edu.cn呀呀呀呀 http://bbs.jlu.edu.cn呵呵 http://www.jlu.edu.cn/proxy.htm http://www.jlu.edu.cn/受伤.htm http://bbs.jlu.edu.cn呵呵 mailto:www@hehe.com哈哈 这样的链接均能判断。 但对于形如 http://.../fdsa.html呵呵 这样的不能判断。好像很难判断了 :( 修改BBSLIB.inc 中的 hhprintf函数 改大约363行的 while(s[0]) 循环 while(s[0]) { if(!strncasecmp(s, "http://", 7) || !strncasecmp(s, "mailto:", 7) || !strncasecmp(s, "ftp://", 6)) { char *tmp,str[1023]; int i,flag=0,sep=0; if(len>0) { buf0[len]=0; hprintf("%s", buf0); len=0; } tmp=strtok(s, "\'\" \r\t)(,;\n"); for(i=0;i<strlen(tmp);i++) { if(tmp[i]=='/') {sep++; continue; } if(isalnum(tmp[i])||tmp[i]=='-'||tmp[i]=='.' ||tmp[i]==':'||tmp[i]=='@') continue; else { if((!strncasecmp(s, "http://", 7) || !strncasecmp(s, "ftp://",6)) && sep==3) break; strcpy(str,tmp+i);tmp[i]='\0';flag=1;break; } } if(tmp==0) break; if(1) { if(strstr(tmp, ".gif") || strstr(tmp, ".jpg") || strstr(tmp, ".bmp")) { printf("<IMG SRC='%s'>", nohtml(tmp)); tmp=strtok(0, ""); if(tmp==0) return; return hhprintf(tmp); } } printf("<a target=_blank href='%s'>%s</a>", nohtml(tmp), nohtml(tmp)); if(!flag) tmp=strtok(0, ""); else { strcpy(tmp,str);} if(tmp==0) return printf("\n"); return hhprintf(tmp); } else { buf0[len]=s[0]; if(len<1000) len++; s++; } } -- ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐◣/◢/◤ │ │ │分│手│之│后│,│我│听│到│你│的│足│╭╮ ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─ ╱╱◣◥╲◤\ ├─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬-∠╱ │音│,│和│落│叶│混│在│了│一│起│…│…│〆 ├─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┤_◢╲◣◥◣◥╲◤▔ ※ 修改:.mOk 于 Mar 16 15:29:34 修改本文.[FROM: 202.198.169.41] ※ 来源:.南京大学小百合站 bbs.nju.edu.cn.[FROM: 202.198.169.41] |
| [返回单文区目录] |
|
|