仓酷云

标题: ASP网页设计操纵xml的类 [打印本页]

作者: 精灵巫婆    时间: 2015-1-16 22:03
标题: ASP网页设计操纵xml的类
在实现ERP等高端的ASP应用时,用户需要提供核心的经营资料,需要ASP商有很高的信用度。楼上说交互性不好,太牵强了吧。在微软提供的一套框架中,利用asp做网站,开发效率高,使用人数少,减少不必要的开销。交互性是互动方式,是有开发人员决定的。<%
Sitevalidator1.0.0
Verysimpleconcept,runthisscriptonyourserver,itrecordsthefiledetailstoan
XMLfilewhichyoudownloadandstore.Then,whenyoucomebacktomakechangesyoucan
runtheXMLfilebackthroughthisscriptanditwilltellyouifanyofthefileshave
beenmodified.Quitesimplereally.
RequiresXMLparserversion3toworkreally.AlsoneedsaccesstotheFileSystemObject.
DimobjRequest,objFSO,sXML,objXML,objNode,objFile,lDifferences,sVersion,sDate
sVersion="1.0.0"
Response.Expires=-1
SetobjRequest=NewProxyRequest
ifUCase(objRequest("action"))="UPLOAD"then
Response.ContentType="text/html"
%>
<HTML>
<HEAD>
<TITLE>ASPValidate,Sitevalidator<%=sVersion%></TITLE>
</HEAD>
<BODY>
<h1>ASPValidate,Sitevalidator<%=sVersion%></h1>
<h2>Author:ChrisRead(<ahref="mailtmrjolly@bigpond.net.au">Mail</a>,<ahref="http://users.bigpond.net.au/mrjolly.">Web</a>)</h2>
<p>Validationresults</p>
<%
SetobjFSO=Server.CreateObject("Scripting.FileSystemObject")
SetobjXML=Server.CreateObject("MSXML2.DOMDocument")
objXML.async=False
sXML=objRequest("xmlupload")
objXML.loadXMLobjRequest.ASCIIToUNICODE(sXML)
lDifferences=0
NowwegothroughtheXMLentriesandvalidateeachoneagainstthatontheserver
ForEachobjNodeinobjXML.documentElement.childNodes
 onerrorresumenext
 SetobjFile=objFSO.GetFile(objNode.getAttribute("path"))
 iferr.number0then
 Problemwiththefile
 Response.Write"<b>"
 Response.WriteobjNode.getAttribute("path")&"<br>"
 Response.Write"^^^^FILEHASBEENREMOVED<br>"
 Response.Write"</b>"
 else
 ifCStr(objFile.DateLastModified)objNode.getAttribute("modified")orCStr(objFile.Size)objNode.getAttribute("size")then
  Response.Write"<b>"
  Response.WriteobjNode.getAttribute("path")&"<br>^^^^Changed,"
  Response.Write"original:"&objNode.getAttribute("modified")&"modified:"&objFile.DateLastModified&","
  Response.Write"was"&objNode.getAttribute("size")&"bytes-now"&CStr(objFile.Size)&"bytes<br>"
  Response.Write"</b>"
  lDifferences=lDifferences+1
 elseifobjRequest("view")""then
  Response.WriteobjNode.getAttribute("path")&"-Filehasnotchanged<br>"
 endif
 endif
 onerrorgoto0
Next
iflDifferences=0then
 Response.Write"<p>Thesitematchesthelastupdate</p>"
else
 Response.Write"<p>"&lDifferences&"difference(s)detectedintheabovefiles</p>"
endif
%>
<ahref="aspvalidate.asp">Backtothemainpage</a>
</BODY>
</HTML>
<%
Response.End
elseifUCase(objRequest.QueryString("action"))="XML"then
SetobjFSO=Server.CreateObject("Scripting.FileSystemObject")
sXML="<?xmlversion=1.0?>"&vbCRLF
sXML=sXML&"<!--GeneratedbySiteValidator"&sVersion&"-->"&vbCRLF
sXML=sXML&"<!--Author:ChrisRead-->"&vbCRLF
sXML=sXML&"<site>"&vbCRLF
sXML=sXML&ProcessFolder(Server.MapPath("/"))
sXML=sXML&"</site>"&vbCRLF
sDate=Year(Date())&"-"&Month(Date())&"-"&Day(Date())
Response.ContentType="text/xml"
Response.AddHeader"Content-Disposition","attachment;filename=site"&sDate&".xml;"
Response.WritesXML
Response.End
else
Response.ContentType="text/html"
%>
<HTML>
<HEAD>
<TITLE>ASPValidate,Sitevalidator<%=sVersion%></TITLE>
</HEAD>
<BODY>
<h1>ASPValidate,Sitevalidator<%=sVersion%></h1>
<h2>Author:ChrisRead(<ahref="mailtmrjolly@bigpond.net.au">Mail</a>,<ahref="http://users.bigpond.net.au/mrjolly.">Web</a>)</h2>
<h3>Itvalidatessites</h3>
<p>Thisscriptwillscanyourentirewebsitefromtherootfolder,andrecordthefilesizesandlastmodifieddatesforallASPpages.
ThisissavedasXML.Then,atalaterdate,whenyouneedtomakeadjustmentsorcheckanything,youcanloadtheXMLinto
thisscriptagainanditlltellyouwhichfileshavechangedandwhen.</p>
ChecksumallASPfilesonthissiteandgenerateanXMLchecksumfile<br>
<ahref="aspvalidate.asp?action=xml&html=0">Right-clickhereandselect"SaveAs"todownloadforASPfilesonly</a><br>
<ahref="aspvalidate.asp?action=xml&html=1">Right-clickhereandselect"SaveAs"todownloadforASPandHTMLfiles</a><br>
<formaction="aspvalidate.asp"method="post"enctype="multipart/form-data"id=form1name=form1>
<br>OR<br><br>
UploadXMLFileofchecksumsandvalidateitagainstthissite<br>
File:<inputtype=filename=xmlupload><br>
Showallresults:<inputtype=checkboxname=view><br>
<inputtype=submitname=actionvalue="Upload">
</form>
</BODY>
</HTML>
<%
Response.End
endif
BitofrecursiontotraversethefolderstructurebuildingXML
FunctionProcessFolder(sFolder)
DimobjFolder,objRoot,objFile,sTemp,sLastModified,sSize
SetobjRoot=objFSO.GetFolder(sFolder)
sTemp=""
ForEachobjFileinobjRoot.Files
 if(Right(objFile.Name,4)=".asp"or((Right(objFile.Name,5)=".html"orRight(objFile.Name,4)=".htm")andRequest("html")=1))andinstr(sFolder&""&objFile.Name,"_vti_cnf")=0then
 sLastModified=objFile.DateLastModified
 sSize=objFile.Size
 sTemp=sTemp&"<filepath="&sFolder&""&objFile.Name&"modified="&sLastModified&"size="&sSize&"/>"&vbCRLF
 endif
Next
ForEachobjFolderinobjRoot.SubFolders
 sTemp=sTemp&ProcessFolder(sFolder&""&objFolder.Name)
Next
SetobjFolder=Nothing
ProcessFolder=sTemp
EndFunction
Requesobjectproxyforuploads.
ClassProxyRequest
PublicClientCertificate
PublicCookies
PublicForm
PublicQueryString
PublicServerVariables
PublicTotalBytes
Privatem_Item
PublicDefaultPropertyGetItem(sIndex)
 Item=m_Item(sIndex)
EndProperty
PrivatesBinaryText
PublicFunctionBinaryRead(lTotalBytes)
 BinaryRead=LeftB(sBinaryText,lTotalBytes)
EndFunction
PrivateSubParseRequest()
 DimsDelimeter
 DimlKeyLength
 DimlBlockEnd
 DimsBlock
 DimsTemp
 DimsField
 DimlStart
 DimlLength
 DimsFilename
 DimsContentType
 DimsContent
 
 sBlock=sBinaryText
 lKeyLength=InstrB(1,sBlock,ChrB(&H0D))-1
 iflKeyLength>0then
 sDelimeter=LeftB(sBlock,lKeyLength)
 lBlockEnd=0
 whilelBlockEnd>=0
  Chopoffthekey,includingtheCR/LFpair
  sBlock=RightB(sBlock,LenB(sBlock)-(lBlockEnd+lKeyLength+2))
  lBlockEnd=InStrB(1,sBlock,sDelimeter)-1
  iflBlockEnd>=0then
   sTemp=LeftB(sBlock,lBlockEnd-2)
   lStart=InStrB(1,sTemp,UNICODEToASCII("name="))+6
   lLength=InStrB(lStart,sTemp,ChrB(34))-lStart
   sField=MidB(sTemp,lStart,lLength)
   lStart=InStrB(1,sTemp,UNICODEToASCII("filename="))+10
   lLength=InStrB(lStart,sTemp,ChrB(34))-lStart
   iflStart>10then
    sFilename=MidB(sTemp,lStart,lLength)
    lStart=InStrB(1,sTemp,UNICODEToASCII("Content-Type:"))+14
    lLength=InStrB(lStart,sTemp,ChrB(&H0D))-lStart
    sContentType=MidB(sTemp,lStart,lLength)
   else
    sFilename=""
    sContentType=""
   endif
   lStart=InStrB(1,sTemp,UNICODEToASCII(vbCRLF&vbCRLF))+4
   lLength=LenB(sTemp)-lStart+1
   sContent=MidB(sTemp,lStart,lLength)
  
   ifASCIIToUNICODE(sFilename)""then
    m_Item.AddASCIIToUNICODE(sField),sContent
    m_Item.AddASCIIToUNICODE(sField)&"_filename",ASCIIToUNICODe(sFilename)
    m_Item.AddASCIIToUNICODE(sField)&"_contenttype",ASCIIToUNICODE(sContentType)
   else
    m_Item.AddASCIIToUNICODE(sField),ASCIIToUNICODE(sContent)
   endif
  endif
 wend
 endif
EndSub
PublicFunctionUNICODEToASCII(sText)
 DimlTemp
 DimobjStream
 
 SetobjStream=Server.CreateObject("ADODB.Stream")
 
 objStream.Open
 
 ForlTemp=1ToLen(sText)
 objStream.WriteTextChrB(Asc(Mid(sText,lTemp,1)))
 Next
 
 objStream.Position=0
 
 UNICODEToASCII=objStream.ReadText
 
EndFunction
PublicFunctionASCIIToUNICODE(sText)
 Dothiswiththestream,avoidingVBScriptstringconcatenation,whichisslowtosaytheleast
 DimlTemp
 DimobjStream
 
 SetobjStream=Server.CreateObject("ADODB.Stream")
 objStream.Open
 
 ForlTemp=1ToLenB(sText)
 objStream.WriteTextMidB(sText,lTemp,1)&ChrB(0),0
 Next
 
 objStream.Position=0
 
 ASCIIToUNICODE=objStream.ReadText
EndFunction
PrivateSubClass_Initialize()
 Setm_Item=Server.CreateObject("Scripting.Dictionary")
 SetClientCertificate=Request.ClientCertificate
 SetCookies=Request.Cookies
 SetForm=Request.Form
 SetQueryString=Request.QueryString
 SetServerVariables=Request.ServerVariables
 TotalBytes=Request.TotalBytes
 sBinaryText=Request.BinaryRead(Request.TotalBytes)
 ParseRequest
EndSub
PrivateSubClass_Terminate()
 SetClientCertificate=Nothing
 SetCookies=Nothing
 SetForm=Nothing
 SetQueryString=Nothing
 SetServerVariables=Nothing
EndSub
EndClass
%>
实现规模效益。与传统的用户拥有硬件软件所有权和使用权以及传统的应用服务商提供一对一的服务模式不同,ASP拥有应用系统所有权,用户拥有使用权,应用系统集中放在ASP的数据中心中,集中管理,分散使用,以一对多的租赁的形式为众多用户提供有品质保证的应用技术服务,实现规模效益。
作者: admin    时间: 2015-1-18 19:48
不是很难但是英文要有一点基础网上的教程很少有系统的详细的去买书吧,另不用专门学习vb关于vbscript脚本在asp教材都有介绍
作者: 山那边是海    时间: 2015-2-2 22:38
多看多学多思。多看一些关于ASP的书籍,一方面可以扩展知识面一方面可以鉴借别人是如何掌握、运用ASP的;多学善于关注别人,向同学老师多多学习,不论知识的大小;多思则是要将学到的知识灵活运用。
作者: 蒙在股里    时间: 2015-2-8 18:58
ASP.Net和ASP的最大区别在于编程思维的转换,而不仅仅在于功能的增强。ASP使用VBS/JS这样的脚本语言混合html来编程,而那些脚本语言属于弱类型、面向结构的编程语言,而非面向对象,这就明显产生以下几个问题:
作者: 乐观    时间: 2015-2-25 23:07
ASP.Net摆脱了以前ASP使用脚本语言来编程的缺点,理论上可以使用任何编程语言包括C++,VB,JS等等,当然,最合适的编程语言还是MS为.NetFrmaework专门推出的C(读csharp),它可以看作是VC和Java的混合体吧。
作者: 谁可相欹    时间: 2015-3-8 10:15
我认为比较好的方法是找一些比较经典的例子,每个例子比较集中一种编程思想而设计的。
作者: 柔情似水    时间: 2015-3-15 22:07
先学习用frontpage熟悉html编辑然后学习asp和vbscript建议买书进行系统学习
作者: 金色的骷髅    时间: 2015-3-22 16:47
下载一个源代码,然后再下载一个VBScript帮助,在源代码中遇到不认识的函数或是其他什么程序,都可以查帮助进行解决,这样学习效率很高。




欢迎光临 仓酷云 (http://ckuyun.com/) Powered by Discuz! X3.2