html.asp

来自「ZD-BS是一个基于asp+access的个人blog系统 程序特点: 1.」· ASP 代码 · 共 347 行

ASP
347
字号
<script language="javascript" runat="server">

//============================================================
//     What's the meaning of Z.G.Z.W.W?
//     Copyright 2006-2008 VAL/ZYI. All Rights Reserved.
//============================================================

function HtmlClass(){

	this.encodeHTML=function(str){
		if(!str) return "";
		str = str.replace(/\&/g, "&amp;");
		str = str.replace(/\>/g, "&gt;");
		str = str.replace(/\</g, "&lt;");
		str = str.replace(/\"/g, "&quot;");
		str = str.replace(/\'/g, "&#39;");
		return str;
	};

	this.encodeURL = function(str){
		if(!str) return "";
		str = str.replace(/\&amp\;/ig,"&");
		str = str.replace(/\&/g, "&amp;");
		str = str.replace(/\>/g, "&gt;");
		str = str.replace(/\</g, "&lt;");
		str = str.replace(/\"/g, "&quot;");
		str = str.replace(/\'/g, "&#39;");
		str = str.replace(/\[/g, "&#91;");
		str = str.replace(/\]/g, "&#93;");
		return str;
	}

	this.trim = function(str){
		if(str==undefined){ return ""; }
		str=str.replace(/(^\s*|\s*$)/g,"");
		str=str.replace(/(\r*\n){3,}/g,"\n\n");
		str=str.replace(/\r/g,"");
		return str;
	};

	this.trimHTML = function(str){
		if(str==undefined){ return ""; }
		str=str.replace(/\<[^\<\>]+\>/g,"");
		str=str.replace(/ +/g," ");
		return str;
	};

	this.trimUBB = function(str){
		if(str==undefined){ return ""; }
		str=str.replace(/\[quote([^\[\]]+|)\](\n*)(\s*)/ig,"\"");
	    str=str.replace(/(\s*)(\n*)\[\/quote\]/ig,"\"");
		str=str.replace(/\[code\](\n*)(\s*)/ig,"\"");
	    str=str.replace(/(\s*)(\n*)\[\/code\]/ig,"\"");
		str=str.replace(/\[hr\]/g,"\n------\n");
    	str=str.replace(/\[(\/|)(b|i|u|s|sup|sub|url[^\]]*|align[^\]]*|size[^\]]*|color[^\]]*|font[^\]]*|list[^\]]*|email[^\]]*|img[^\]]*|swf[^\]]*|wmp[^\]]*|qt[^\]]*|rm[^\]]*)\]/ig,"");
		str=str.replace(/\[\*\]/g,"*");
		str=str.replace(/ +/g," ");

		return str;
	};

	this.cleanHTML = function(str){
		if(str==undefined){ return ""; }
		str=str.replace(/\<(scr)(ipt)([^\<\>]+)\>/ig,"&lt;script$3&gt;");
		str=str.replace(/\<\/(scr)(ipt)\>/ig,"&lt;/script&gt;");
		str=str.replace(/\<iframe(\/| \/|)\>/ig,"&lt;iframe$1&gt;");
		str=str.replace(/\<\/iframe\>/ig,"&lt;/iframe&gt;");
		str=str.replace(/\<br(\/| \/|)\>/ig,"<br />");
		return str;
	};

	this.keyword=function(str){
		if(!str) return "";
		theCache.getKeyword();
		var arrWord=theCache.keyword;
		if(arrWord!=null){
			for(var i=0;i<arrWord.length;i++){
				var re=new RegExp("((<a [^<>]*?>[^(<\/a>)]*?"+arrWord[i]["name"]+"[^(<a )]*?<\/a>)|(<[^>]*?"+arrWord[i]["name"]+"[^<]*?>))","gi");
				var arrMach;
				var j=0,arrTmp=new Array(),strNew;
				while((arrMach=re.exec(str))!=null){
					arrTmp[j]=arrMach[1];
					strNew="<zd-keyword />";
					str=str.replace(arrMach[0],strNew);
					re.lastIndex+=strNew.length-arrMach[0].length;
					j++;
				}
				str=str.replace(new RegExp(arrWord[i]["name"],"gi"),"<a "+(arrWord[i]["URL"]?"href=\""+arrWord[i]["URL"]+"\" ":"")+(arrWord[i]["describe"]?"title=\""+arrWord[i]["describe"]+"\" ":"")+" target=\"_blank\">"+arrWord[i]["name"]+"</a>");
				re=/<zd\-keyword \/>/gi;
				j=0;
				while((arrMach=re.exec(str))!=null){
					strNew=arrTmp[j];
					str=str.replace(arrMach[0],strNew);
					re.lastIndex+=strNew.length-arrMach[0].length;
					j++;
				}
			}
		}
		return str;
	};

	this.strLength=function(str){
		if(!str) return 0;
		var tLen=0,charCode;
		for(var i=0;i<str.length;i++){
			charCode=str.charCodeAt(i);
			if(charCode<0||charCode>255){ tLen+=2 }else{ tLen++ }
		}
		return tLen;
	}

	this.sliceStr=function(str,intLength,strFollow,bCheckChar){
		if(!str) return "";
		if(!intLength) return str;
		if(!strFollow) strFollow="";
		if(!bCheckChar){
			if(str.length>intLength){ str=str.slice(0,intLength)+strFollow; }
		}else{
			var tLen=0,charCode;
			for(var i=0;i<str.length;i++){
				charCode=str.charCodeAt(i);
				if(charCode<0||charCode>255){ tLen+=2 }else{ tLen++ }
				if(tLen>=intLength){
					str=str.substr(0,i)+"...";
					break;
				}
			}
		}
		return str;
	};

	this.urlLink=function(strURL,strContent,bTarget,strTitle,strBase){
		var str="";
		if(!strURL) return strContent;
		if(!strBase) strBase=zd_set["blogURL"];
		if(func.checkEmail(strURL)){
			strURL="mailto:"+strURL;
		}else if(strURL.search(/^http\:\/\//i)==-1){
			strURL=strBase+strURL;
		}
		if(!strContent) strContent=strURL;
		str='<a href="'+strURL+'"';
		if(strTitle) str+=' target="_blank"';
		if(strTitle) str+=' title="'+strTitle+'"';
		str+='>'+strContent+'</a>';
		return str;
	};

	this.pageLink=function(intPageCount,intAPage,strMainURL,strPlusURL,bStatic,bSimple){
		var strURL="",str="";
		//var arr=new Array();
		if(strPlusURL==undefined) strPlusURL="";
		if(bStatic){
			strURL+=strMainURL+"?/"+strPlusURL+"p{$}.html";
		}else{
			strURL+=strMainURL+"?page={$}";
			if(strPlusURL.indexOf("=")!=-1){
				strURL+="&"+strPlusURL;
			}else{
				strURL+=strPlusURL;
			}
		}
		var intMax=10;
		var bMax=false;
		var i=1;
		if(intAPage>=intMax){
			i=intAPage-intMax+2;
			bMax=true;
		}
		if(!bSimple){
			for(;i<=intPageCount&&i<=(bMax?intMax+intAPage-intMax+1:intMax);i++){
				if(intAPage==i){
					str+="<strong>"+i+"</strong> ";
				}else{
					str+=this.urlLink(strURL.replace(/\{\$\}/,i),i)+" ";
				}
			}
			if(intAPage>1){
				str=this.urlLink(strURL.replace(/\{\$\}/,intAPage-1),"[<]")+" "+str;
				str=this.urlLink(strURL.replace(/\{\$\}/,1),"[<<]")+" "+str;
			}
			if(intAPage<intPageCount){
				str+=this.urlLink(strURL.replace(/\{\$\}/,intAPage+1),"[>]")+" ";
				str+=this.urlLink(strURL.replace(/\{\$\}/,intPageCount),"[>>]");
			}
		}else{
			if(intAPage>1){
				str+="<td width=\"50%\">"+this.urlLink(strURL.replace(/\{\$\}/,intAPage-1),"<< Previous")+"</td>";
			}
			if(intAPage<intPageCount){
				str+="<td width=\"50%\" align=\"right\">"+this.urlLink(strURL.replace(/\{\$\}/,intAPage+1),"Next >>")+"</td>";
			}
			str="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"99%\" align=\"center\"><tr>"+str+"</tr></table>"
		}
		return str;
	};

	this.ubb=function(str,bAutoURL){
		//html encode
		str=this.encodeHTML(str);
		str=str.replace(/( ){2}/g,"&nbsp;&nbsp;");
		str=str.replace(/\n/g,"<br />");
		
		//auto URL
		if(bAutoURL){
			var re=/([^\=\]][\s]*?|^)(http|https|rstp|ftp|mms|ed2k):\/\/(.*?)(\>|\<|\&nbsp\;|\&quot\;|\&gt\;|\&lt\;|\)|\(|$| )/igm;
			var arrMach;
			var strURL,strNew;
			while((arrMach=re.exec(str))!=null){
				strURL=arrMach[2]+"://"+func.checkUrl(arrMach[3]);
				strNew=arrMach[1]+"<a href=\""+strURL+"\" target=\"_blank\">"+strURL+"</a>"+arrMach[4];
				str=str.replace(arrMach[0],strNew);
				re.lastIndex+=strNew.length-arrMach[0].length;
			}
		}

		return str;
	};

}

function prt(str){ Response.Write(str); }

function globalMsgBox(strMsg){
	var str='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	str+='<html xmlns="http://www.w3.org/1999/xhtml">\n';
	str+='<head>\n';
	str+='<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n';
	str+='<title>System Message</title>\n';
	str+='</head>\n';
	str+='<body>'+strMsg+'</body>\n';
	str+='</html>';
	prt(str);
}

function errorMsg(strError){
	var str='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	str+='<html xmlns="http://www.w3.org/1999/xhtml">\n';
	str+='<head>\n';
	str+='<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n';
	str+='<title>Error Message</title>\n';
	str+='</head>\n';
	str+='<body style="margin:0;padding:0;font-size:12px;color:#777;font-family:Verdana;">\n';
	str+='<div style="width:420px;margin:40px auto 0 auto;background-color:#191919;color:#8CC165;padding:6px;font-weight:bold;">Error</div>\n';
	str+='<div style="width:420px;margin:0px auto;padding:6px;"><ul style="margin:0 4px;list-style-type:none;line-height:200%;">'+strError+'</ul></div>\n';
	str+='<div style="width:420px;margin:20px auto;text-align:center;font-size:11px;">ZD-BS &copy;2008 VAL</div>';
	str+='</body>\n';
	str+='</html>';
	prt(str);
}

function completeMsg(strComplete,redirectURL){
	var str='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	str+='<html xmlns="http://www.w3.org/1999/xhtml">\n';
	str+='<head>\n';
	str+='<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n';
	str+='<title>Complete Message</title>\n';
	str+='</head>\n';
	str+='<body style="margin:0;padding:0;font-size:12px;color:#777;font-family:Verdana;">\n';
	str+='<div style="width:420px;margin:40px auto 0 auto;background-color:#191919;color:#8CC165;padding:6px;font-weight:bold;">Complete</div>\n';
	str+='<div style="width:420px;margin:0px auto;padding:6px;"><ul style="margin:0 4px;list-style-type:none;line-height:200%;">'+strComplete+'</ul></div>\n';
	if(redirectURL){
		str+='<div style="width:420px;margin:0px auto;padding:6px;text-align:center;"><a href="'+redirectURL+'" style="color:#FF9999;">Go Back</a></div>\n';
	}
	str+='<div style="width:420px;margin:20px auto;text-align:center;font-size:11px;">ZD-BS &copy;2008 VAL</div>';
	str+='</body>\n';
	str+='</html>';
	prt(str);
}

function loginBox(){
	var str='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	str+='<html xmlns="http://www.w3.org/1999/xhtml">\n';
	str+='<head>\n';
	str+='<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n';
	str+='<title>User Login</title>\n';
	str+='<style type="text/css">td{padding:20px 0 0 0;}</style>\n'
	str+='</head>\n';
	str+='<body style="margin:0;padding:0;font-size:12px;color:#777;font-family:Verdana;">\n';
	str+='<form name="commPost" method="post" action="login.asp">\n';
	str+='<input type="hidden" name="formPost" value="1" />\n';
	str+='<div style="width:420px;margin:40px auto 0 auto;background-color:#191919;color:#8CC165;padding:6px;font-weight:bold;">User Login</div>\n';
	str+='<div style="width:420px;margin:0 auto;padding:6px">\n';
	str+='<table border="0" cellspacing="0" cellpadding="0" align="center" width="100%">\n';
	str+='<tr><td width="80">UserName: </td><td><input type="text" name="username" style="border:0;border-bottom:#999999 1px solid;font-size:12px;padding:0px;width:120px;" /></td></tr>\n';
	str+='<tr><td>PassWord: </td><td><input type="password" name="password" style="border:0;border-bottom:#999999 1px solid;font-size:12px;padding:0px;width:120px;" /></td></tr>\n';
	str+='<tr><td colspan="2"><input type="submit" name="post" value="Login" style="padding:2px 16px;border:0;background-color:#333333;color:white;" /> <input type="button" value="Back" onclick="window.location.href=\''+zd_set["blogURL"]+'\'" style="padding:2px 16px;border:0;background-color:#333333;color:white;" /></td></tr>\n';
	str+='</table>\n';
	str+='</form>\n';
	str+='<div style="width:420px;margin:20px auto;text-align:center;font-size:11px;">ZD-BS &copy;2008 VAL</div>\n';
	str+='</body>\n';
	str+='</html>';
	prt(str);
}

function registerBox(){
	var str='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	str+='<html xmlns="http://www.w3.org/1999/xhtml">\n';
	str+='<head>\n';
	str+='<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n';
	str+='<title>User Register</title>\n';
	str+='<style type="text/css">td{padding:20px 0 0 0;}</style>\n'
	str+='</head>\n';
	str+='<body style="margin:0;padding:0;font-size:12px;color:#777;font-family:Verdana;">\n';
	str+='<form name="commPost" method="post" action="login.asp?act=reg">\n';
	str+='<input type="hidden" name="formPost" value="1" />\n';
	str+='<div style="width:420px;margin:40px auto 0 auto;background-color:#191919;color:#8CC165;padding:6px;font-weight:bold;">User Register</div>\n';
	str+='<div style="width:420px;margin:0 auto;padding:6px">\n';
	str+='<table border="0" cellspacing="0" cellpadding="0" align="center" width="100%">\n';
	str+='<tr><td width="80">UserName: </td><td><input type="text" name="username" style="border:0;border-bottom:#999999 1px solid;font-size:12px;padding:0px;width:120px;" /></td></tr>\n';
	str+='<tr><td>Password: </td><td><input type="password" name="password" style="border:0;border-bottom:#999999 1px solid;font-size:12px;padding:0px;width:120px;" /></td></tr>\n';
	str+='<tr><td>Password: </td><td><input type="password" name="repassword" style="border:0;border-bottom:#999999 1px solid;font-size:12px;padding:0px;width:120px;" /> (Again)</td></tr>\n';
	str+='<tr><td>EmailAddr: </td><td><input type="text" name="email" style="border:0;border-bottom:#999999 1px solid;font-size:12px;padding:0px;width:120px;" /></td></tr>\n';
	str+='<tr><td>Homepage: </td><td><input type="text" name="homepage" style="border:0;border-bottom:#999999 1px solid;font-size:12px;padding:0px;width:120px;" /></td></tr>\n';
	str+='<tr><td>Secucode: </td><td><input type="text" name="sCode" style="border:0;border-bottom:#999999 1px solid;font-size:12px;padding:0px;width:120px;" /> <img src="scode.asp" style="vertical-align:middle;" /></td></tr>\n';
	str+='<tr><td colspan="2"><input type="submit" name="post" value="Register" style="padding:2px 16px;border:0;background-color:#333333;color:white;" /> <input type="button" value="Back" onclick="window.location.href=\''+zd_set["blogURL"]+'\'" style="padding:2px 16px;border:0;background-color:#333333;color:white;" /></td></tr>\n';
	str+='</table>\n';
	str+='</form>\n';
	str+='<div style="width:420px;margin:20px auto;text-align:center;font-size:11px;">ZD-BS &copy;2008 VAL</div>\n';
	str+='</body>\n';
	str+='</html>';
	prt(str);
}

function debugBox(arr){
	var str='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
	str+='<html xmlns="http://www.w3.org/1999/xhtml">\n';
	str+='<head>\n';
	str+='<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n';
	str+='<title>Debug Infomation</title>\n';
	str+='</head>\n';
	str+='<body style="margin:0;padding:0;font-size:12px;color:#777;font-family:Verdana;">\n';
	str+='<div style="width:540px;margin:40px auto 0 auto;border:#333333 1px solid;padding:0px;font-weight:bold;">\n';
	str+='<div style="padding:8px;font-weight:bold;background-color:#333333;color:white;">ZD-BS Debug System</div>\n';
	str+='<table border="0" cellspacing="1" cellpadding="8" align="center" width="100%">\n';
	for(var i=0;i<arr.length;i++){
		str+='<tr style="background-color:#FFD850;"><td width="50%">'+arr[i]["key"]+'</td><td width="50%">'+arr[i]["value"]+'</td></tr>\n';
	}
	str+='</table>\n';
	str+='</div>\n'
	str+='<div style="width:420px;margin:20px auto;text-align:center;font-size:11px;">ZD-BS &copy;2008 VAL</div>\n';
	str+='</body>\n';
	str+='</html>';
	prt(str);
}

</script>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?