寫這個小東西的出發點,由于經常的需要在線利用asp腳本的ado對數據庫執行建表,修改字段 每次都要ftp修改升級文件傳上去或在線修改好了運行!很是麻煩 于是寫了這個小東西!很方便~~
腳本特點: 1.可以運行除了 ssi(如#include file) 和 預處理指令(如@ language=javascript)外的任何 asp vbscript 腳本 比如數據庫連接,記錄集的建立,甚至Fso等 2.并可運行<%%> <%=%> HTML混編的 ASP腳本 3.有簡單的容錯處理機制,可以簡單的知道是腳本那個部分錯誤 4.具有驗證碼登陸,密碼和用戶名在代碼runasp.asp 的頭部修改,缺省提供的是帳號:admin 密碼:admin
看起來這個腳本很簡陋,其實功能極其強大的可怕! 雖然有簡單的登陸驗證,但還是不建議你使用在你的站點上,做為一個輔助調試asp代碼的小工具 個人認為比較實用的!所以你可以自己測試,玩玩,或作為臨時的論壇代碼解決問題的測試工具! 因為每次都要進入調試環境來運行asp的確麻煩! 還需要注意一點的是象 <td width=50%> 的50%一定要寫加引號
演示(admin 密碼admin): www.paintblue.net/myasp/runasp.asp (實際執行功能已經屏蔽,請下載或粘貼下面代碼測試使用):
下載: http://www.paintblue.net/myasp/runasp.rar
<% @ LANGUAGE="VBSCRIPT" %> <%Option Explicit response.buffer=true dim Spassword,SUserName SUserName="admin" Spassword="admin" dim SQLMutiStr dim i dim action action=request.querystring("action")
IF action="GetCode" then '---------TOT NumCodeJS ELSE '--------TOT Response.Write("<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">") Response.Write("<HTML>") Response.Write("<HEAD>") Response.Write("<TITLE>ASP RunCode SCR V1.0 / Create By PaintBlue.Net V37</TITLE>") Response.Write("<META NAME=""Generator"" CONTENT=""EditPlus,V37,PaintBlue.Net"">") Response.Write("<META NAME=""Author"" CONTENT=""V37,PaintBlue.Net"">") Response.Write("<META NAME=""Keywords"" CONTENT=""PaintBlue.Net,,V37,RunCode,ASP,Script,BlueIdea.COM,Lfgbox.com"">") Response.Write("<META NAME=""Description"" CONTENT=""運行ASP代碼的ASP腳本!"">") Response.Write("</HEAD>") Response.Write("<BODY bgcolor=#D4D0C8>")
SQLMutiStr=trim(Request.Form("SQLMutiStr")) if session("login")="" and action="chkpass" then session("login")=checkPass() end if if action="exit" then session("login")="" if session("login")="1" then if action="RunCode" then if SQLMutiStr="" then Response.write "沒有輸入要運行的代碼!" Response.write "<br><br><a href=""javascript:window.history.back();"">返回運行頁面</a><br><br>" Response.write "<a href=""?action=exit"">退出登陸</a>" response.end else dim ExeStrArr dim re dim tempSQL,tempSQL2 dim ScriptArr,ScriptSubArr tempSQL2="" tempSQL=split(SQLMutiStr,vbcrlf) if inStr(lcase(tempSQL(0)),"language")>0 then tempSQL2=tempSQL(1) if ubound(tempSQL)>1 then for i=1 to ubound(tempSQL) tempSQL2=tempSQL2&tempSQL(i) next end if tempSQL2=trim(tempSQL2) else tempSQL2=SQLMutiStr end if tempSQL2=replace(tempSQL2,"<%"&"=","<"&"%response.write ") do tempSQL2=replace(tempSQL2,vbcrlf&vbcrlf,vbcrlf) loop while instr(tempSQL2,vbcrlf&vbcrlf)>0 tempSQL2=trim(tempSQL2) tempSQL2="<"&"%%"&">"&tempSQL2&"<"&"%%"&">" ScriptArr=split(tempSQL2,"%"&">") dim ub,kub ub=ubound(ScriptArr) for i=0 to ub-1 ScriptSubArr=split(ScriptArr(i),"<"&"%") if i>0 then response.write (ScriptSubArr(0)) ExeCuteIt(ScriptSubArr(1)) next call EndProc("<font color=#009900>代碼運行完畢!</font>") end if else %> 輸入要運行的ASP代碼: <FORM METHOD=POST ACTION="?action=RunCode" style="margin:0px;"> <TEXTAREA NAME="SQLMutiStr" wrap='OFF' ROWS="20" style="width:100%;height:100%;table-layout:fixed;word-break:break-all;"><%=Server.Htmlencode(SQLMutiStr)%></TEXTAREA> <br> <INPUT TYPE="button" onclick="window.location.href='?action=exit';" Value="LouOut"> <INPUT TYPE="reset" Value="Clear"> <INPUT TYPE="submit" value="Run AspCode"> </FORM> <% end if else call loginmain() end if Response.write ("</BODY></HTML>") END IF '-------TOT
SUB loginMain() %>
<FORM METHOD=POST ACTION="?action=chkpass"> UserName:<INPUT TYPE="text" NAME="UserName"><br> PassWord:<INPUT TYPE="password" NAME="Runpassword"><br> CheckCode:<INPUT TYPE="GetCode" NAME="GetCode"><img src="runasp.asp?action=GetCode&Time=<%=timer()%>"><br> <br><img width=125 height=0><INPUT TYPE="submit" value=" Login "></FORM> <% End SUB
function checkPass() dim UserName,Runpassword,GetCode dim errinfo checkPass="" UserName=trim(request.form("UserName")) Runpassword=trim(request.form("Runpassword")) GetCode=request.form("GetCode") if UserName="" or Runpassword="" then errinfo=errinfo&"<li>用戶名和密碼輸入不能為空" end if if Not isnumeric(GetCode) then errinfo=errinfo&"<li>請輸入數字校驗碼" end if if errinfo<>"" then call loginmain() EndProc errinfo end if if action="chkpass" and Session("GetCode")=int(GetCode) and UserName=SUserName and Runpassword=Spassword then Session("GetCode")=0 checkPass="1" else call loginmain() EndProc "登陸失敗!請重新確認正確輸入" end if End function
SUB ExeCuteIt(ExString) on error resume next Execute(ExString) if err.number<>0 then Response.write "<div style=""background-color: #ffeedd;padding: 6px;"">" Response.write "<hr size=1>" Response.write "出錯信息:<li><font color=#ff0000>"&err.description&"</font>" Response.write "<hr size=1>" Response.write "出錯代碼:<li><font color=#0000ff>"&Htmlencode(ExString)&"</font>" Response.write "<hr size=1></div>" end if on error goto 0 end SUB
function HTMLEncode(reString) dim Str:Str=reString if not isnull(Str) then Str = replace(Str, ">", ">") Str = replace(Str, "<", "<") Str = Replace(Str, CHR(32), " ") Str = Replace(Str, CHR(9), " ") Str = Replace(Str, CHR(34), """) ' " Str = Replace(Str, CHR(39), "'") ' ' Str = Replace(Str, CHR(13), "") Str = Replace(Str, CHR(10) & CHR(10), "</P><P> ") Str = Replace(Str, CHR(10), "<BR> ") HTMLEncode = Str else HTMLEncode="" end if end function
'斷點調試 num=0 中斷 Sub Response_write(str,num) dim istr:istr=str dim inum:inum=num response.write str&"<br>" if inum=0 then response.end end sub
SUB EndProc(info) Response.write "<hr size=1 color=#00aa00>" Response.write info Response.write "<hr size=1 color=#00aa00><a href=""javascript:window.history.back();"">返回運行頁面</a><br><br>" Response.write "<a href=""?action=exit"">退出登陸</a>" response.end End SUB %> <script language="JScript" runat="Server"> function GetNO(num){ var NumArray=[ ["0","0","0","3c","66","66","66","66","66","66","66","66","3c","0","0","0"], ["0","0","0","30","38","30","30","30","30","30","30","30","30","0","0","0"], ["0","0","0","3c","66","60","60","30","18","c","6","6","7e","0","0","0"], ["0","0","0","3c","66","60","60","38","60","60","60","66","3c","0","0","0"], ["0","0","0","30","30","38","38","34","34","32","7e","30","78","0","0","0"], ["0","0","0","7e","6","6","6","3e","60","60","60","66","3c","0","0","0"], ["0","0","0","38","c","6","6","3e","66","66","66","66","3c","0","0","0"], ["0","0","0","7e","66","60","60","30","30","18","18","c","c","0","0","0"], ["0","0","0","3c","66","66","66","3c","66","66","66","66","3c","0","0","0"], ["0","0","0","3c","66","66","66","66","7c","60","60","30","1c","0","0","0"] ]; var str=[]; num=String(num).split(""); for(var i=0;i<NumArray[0].length;i++) for(var j=0;j<num.length;j++) str[str.length]=("0x"+NumArray[num[j]][i]); var str1="#define counter_width "+j*8; var str2="#define counter_height 16"; return str1+String.fromCharCode(13,10)+str2+String.fromCharCode(13,10)+"static unsigned char counter_bits[]={"+str+"}"; } function GetRnd(Num){ return Math.floor(Math.random()*Math.pow(10,Num)); } function NumCodeJS() { Response.buffer=true var zNum; var zNum=GetRnd(4); if (zNum<1000) zNum+=999; Session("GetCode") = zNum; Response.ContentType="image/x-xbitmap"; Session("GetCode") = zNum; Response.Write(GetNO(zNum)); } </script> [Ctrl+A 全部選擇 提示:你可先修改部分代碼,再按運行]
代碼思路: 1.使用 vbs的 execute() 命令執行 字串的強大功能! 這個命令有時候很有用,特別是可以把你的腳本當一個方便的字串處理,完成后再調用 execute 執行運行! 由于execute的執行代碼效率比較低,所以實際使用中用的非常少! 我比較過執行只要 50ms的代碼,改用execute 來執行后串升到 200ms 2.對 提交的 asp腳本表單的處理! 先對 <%=aaaa%>做替換成 <%response.write aaaa%> 然后,程序對其在頭和尾分別加上一對<%%> form 代碼 <%%> 然后對<% 和%>分別執行split二次分割!就能有規律的取得 Html代碼和 純asp 代碼兩部分! 然后對 html段的數組成員直接 response.write 對 純asp代碼的數組成員執行 execute 這樣對每段 asp code執行 on error resume next 取 err.description 就大致了解asp出錯信息了 ----------------------------------------------------------------------------------------- (Created by PaintBlue.Net V37 2003-12-10)
|