首页 | 心情日记 | 建站心得 | 编程技术 | 大盘分析 | 股市信息 | 学习园地 | 电脑技巧 | 物流外贸 | 另类其它 | 站长推荐 | 给我留言 | 相册

用户登陆
用户:
密码:
 
不保存保存一天
保存一月保存一年

站点日历
73 2024 - 4 48
 123456
78910111213
14151617181920
21222324252627
282930


站点统计

最新评论

日志搜索

 标题   内容


ASP操作EXCEL 12月28日大盘分析
未知 视频地址加密\解密   [ 日期:2009-12-27 19:23:21 ]   [ 来自:本站原创 ]

海外邮件中继,海外退信中继,美国高速VPS,不限流量VPN,邮局维护和管理,邮件网关,EMOS邮件中继,POSTFIX邮件中继,Winwebmail邮件中继,Winmail邮件中继,DBMail邮件中继,JDMail邮件中继,Exchange邮件中继,MDaemon邮件中继 淘宝店:http://shantan.taobao.com 云邮科技官网:www.yunrelay.com

【字体设置:
URLEncode

  URLEncode 方法可以将指定字符串进行URL编码。 

  语法

  Server.URLEncode( string )

  参数 

  string 指定要转化的字符串 

  Example

  下面是代码:

  < % Respones.Write(Server.URLEncode("http://www.microsoft.com"))% > 

  显示为:

  http%3A%2F%2Fwww%2Emicrosoft%2Ecom 


在asp.net 解码的方法是:server.urlencode,在ASP中没有带对应的解码函数,只有自定义:

1.
<%
response.write "原码:" & "mms%3a%2f%2fmedia.chinabroadcast.cn%2fchi%2fnet_radio%2fentertainment%2fei041118002.wmv" & "<BR>"
response.write "编码后:" & server.URLEncode("mms%3a%2f%2fmedia.chinabroadcast.cn%2fchi%2fnet_radio%2fentertainment%2fei041118002.wmv") & "<BR>"
response.write "解码后:" & urldecode(server.URLEncode("mms%3a%2f%2fmedia.chinabroadcast.cn%2fchi%2fnet_radio%2fentertainment%2fei041118002.wmv"))

Function URLDecode(enStr)
Dim deStr
Dim tempC,tempI,tempV
deStr=""
For tempI=1 to len(enStr)
tempC=Mid(enStr,tempI,1)
IF tempC="%" Then
tempV=eval("&h"+Mid(enStr,tempI+1,2))
IF tempV<128 Then
deStr=deStr&chr(tempV)
tempI=tempI+2
Else
IF isvalidhex(mid(enstr,tempI,3)) then
IF isvalidhex(mid(enstr,tempI+3,3)) then
tempV=eval("&h"+Mid(enStr,tempI+1,2)+Mid(enStr,tempI+4,2))
deStr=deStr&chr(tempV)
tempI=tempI+5
Else
tempV=eval("&h"+Mid(enStr,tempI+1,2)+cstr(hex(asc(Mid(enStr,tempI+3,1)))))
deStr=deStr&chr(tempV)
tempI=tempI+3 
End IF 
Else 
destr=destr&tempC
End IF
End IF
Else
IF tempC="+" then
deStr=deStr&" "
Else
deStr=deStr&tempC
End IF
End IF
Next
URLDecode=deStr
End Function

Function isvalidhex(str)
Dim tempD
isvalidhex=true
str=ucase(str)
IF len(str)<>3 Then isvalidhex=false:exit function
IF left(str,1)<>"%" Then isvalidhex=false:exit function
tempD=mid(str,2,1)
IF not (((tempD>="0") and (tempD<="9")) or ((tempD>="A") and (tempD<="Z"))) Then isvalidhex=false:exit function
tempD=mid(str,3,1)
IF not (((tempD>="0") and (tempD<="9")) or ((tempD>="A") and (tempD<="Z"))) Then isvalidhex=false:exit function
End Function
%>

2.

<% 
function urldecoding(vstrin) 
dim i,strreturn,strSpecial 
strSpecial = "!""#$%&'()*+,./:;<=>?@[]^`{|}~%" 
strreturn = "" 
for i = 1 to len(vstrin) 
thischr = mid(vstrin,i,1) 
if thischr="%" then 
intasc=eval("&h"+mid(vstrin,i+1,2)) 
if instr(strSpecial,chr(intasc))>0 then 
strreturn= strreturn & chr(intasc) 
i=i+2 
else 
intasc=eval("&h"+mid(vstrin,i+1,2)+mid(vstrin,i+4,2)) 
strreturn= strreturn & chr(intasc) 
i=i+5 
end if 
else 
if thischr="+" then 
strreturn= strreturn & " " 
else 
strreturn= strreturn & thischr 
end if 
end if 
next 
urldecoding = strreturn 
end function 
%> 
<%=urldecoding("mms%3a%2f%2fmedia.chinabroadcast.cn%2fchi%2fnet_radio%2fentertainment%2fei041118002.wmv")%>


3.

利用XMLHTTP方法。
让Request那个东西解析它,然后把内容返回过来
2个文件
第一个:url.asp
代码如下。。
<%@Language="JavaScript"%>
<%
function getURL(f_url) {
var pat = //[^./]+.[A-Za-z]+/;
var url = "http://"; 
url += Request.ServerVariables("HTTP_HOST");
url += Request.ServerVariables("URL");
url = url.replace(pat, "");
url += "/" + f_url;
return url;
}

function changeCode(f_val) {
var url = getURL("ChangeCode.asp") + "?Val=" + f_val;
var obj = Server.CreateObject("Microsoft.XMLHTTP");
obj.Open("POST", url, false);
obj.Send(null);
var nStrng = unescape(obj.responseText);
obj = null;
return nStrng;
}


var str = "mms%3a%2f%2fmedia.chinabroadcast.cn%2fchi%2fnet_radio%2fentertainment%2fei041118002.wmv";
Response.Write(changeCode(str));
%>
第二个文件ChangeCode.asp
代码如下。。。
<%@Language="JavaScript"%>
<%
var strng = Request.QueryString("Val");
strng = escape(strng);
Response.Write(strng);
%>
虽然比较麻烦,但是为了效果要不则手段。


--------------------------------------------------------------------------------------------------------------------------------- 
function urldecode(encodestr) 
newstr="" 
havechar=false 
lastchar="" 
for i=1 to len(encodestr) 
char_c=mid(encodestr,i,1) 
if char_c="+" then 
newstr=newstr & " " 
elseif char_c="%" then 
next_1_c=mid(encodestr,i+1,2) 
next_1_num=cint("&H" & next_1_c) 

if havechar then 
havechar=false 
newstr=newstr & chr(cint("&H" & lastchar & next_1_c)) 
else 
if abs(next_1_num)<=127 then 
newstr=newstr & chr(next_1_num) 
else 
havechar=true 
lastchar=next_1_c 
end if 
end if 
i=i+2 
else 
newstr=newstr & char_c 
end if 

next 
urldecode=newstr 
end function



暂时没有评论
   发表评论 - 不要忘了输入验证码哦!
作者: 用户:  密码:  我要注册 验证码: 
为防止广告注册机程序,验证码不会自动显示,请点击此处显示或者(刷新)验证码!
评论:

禁止表情
禁止UBB
禁止图片
识别链接
识别关键字
确定发布?
最多可以输入200个字,目前你已经输入了0个字;你今日还可以发表10条评论!
 
   

CopyRight © 2008-2010 广东金融学院030904班 All Rights Reserved
Powered by www.030904.com