ASP + as2.0 + XML

Source: Internet
Author: User

About configuration control panel ---- add or delete programs ---- add Windows Components ----- IIS. After adding the content, go to your control panel-management tools-Internet Information Service, double-click the icon on the left to expand-find the default website-right-click-create-virtual directory (find the prompt ); similarly, when you right-click --- properties ----- Directory Security ---- edit ---- anonymous access, IIS is allowed to control the password...
The configuration is successful without an accident.
Detection: Create an ASP file in your virtual directory <% = now () %> and view it as the current time.
Haha... Note that the format of your disk is very different between fat and NTFS in terms of file protection. Fat is easier to read and write files.

For interaction, SWF files read data from ASP again. SWF also writes data to the database through ASP.
Content: read/write database (paging), read/write cookies, read/write notepad, Session Object
ASP (VB) + flash + XML + Access

ASP read database:

<% @ Language = "VBScript" @ codePage = "936" %> <% 'this statement is encoded in the gb2312 option explicit variable declaration response. contenttype = "text/XML" 'Document Type xmldim Conn, connstr, SQL, I, RS, CK, label, page, page_size, count, maxpagei = 1page_size = 10 connstr = "provider = Microsoft. jet. oledb.4.0; Data Source = "& server. mappath ("data. mdb ") &"; "set conn = server. createobject ("ADODB. connection ") set rs = server. createobject ("ADODB. recordset ") Conn. open connstrsql = "Select [ID] from [Book]" Rs. open SQL, Conn, all reads are written as all writes are written as 3, 3 is the fastest way to query and write, is the count = RS that daren said. recordcount 'Total number of records maxpage = count/page_sizers.closeif count mod page_size <> 0 then maxpage = int (maxpage) + 1end if page = trim (Request ("page ")) if page = "" Then page = 1end if isnumeric (PAGE) = false then' checks whether it is a number response. 'end' this is also very important else page = int (PAGE) end ifif page <1 then page = 1end ifif page> maxpage then page = ma Xpageend if '''''''''''''''''''''''''''''''''''''' ''''' ''' the above section is only used to obtain the total number of pages. If page = 1 then SQL = "select top "& page_size &" * from [Book] Where (ID <= (select top 1 [ID] from [Book] Order by id desc )) order by id desc "else SQL =" select top "& page_size &" * from [Book] Where (ID <(select Min (ID) from (select top "& page_size * (page-1) &" [ID] from [Book] Order by id desc) Order by id desc "'virtual table In this case, select top "& page_size * (page-1) &" [ID] from [Book] Order by id desc and then select Min (ID) from (select top "& page_size * (page-1) &" [ID] from [Book] Order by id desc) Finally, let's look at the entire statement end if RS. open SQL, Conn, 1, 1response. write ("<? XML version = '1. 0' encoding = 'gb2312 '?> <Book page = '"& maxpage &"'> ") do while not Rs. eofresponse. write ("<part admin = '" & RS ("admin") & "'name ='" & RS ("name ") & "'title = '" & RS ("title") & "'qq ='" & RS ("QQ ") & "'emaill = '" & RS ("emaill") & "' from = '" & RS ("from ") & "'image1 = '" & RS ("image1") & "'time1 ='" & RS ("time1 ") & "'image2 = '" & RS ("image2") & "'time2 ='" & RS ("time2 ") & "'IP = '" & RS ("ip") & "'> <content> <! [CDATA ["& RS (" content1 ") &"]> </content> <! [CDATA ["& RS (" content2 ") &"]> </content> </Part> ") rs. movenexti = I + 1loopresponse. write ("</book>") rs. closeconn. closeset rs = nothingset conn = nothing ''''''''''''''''''''''''''''''''' ''' & equal to the + number in other languages

ASP write database:

<% @ Language = "VBScript" @ codePage = "936" %> <% option explicitresponse. contenttype = "text/html" 'declare dim time1, QQ, time2, CK, iptime1 = now () CK = request. form ("ck") 'accepts the variable sent by post and accepts the variable sent by get as CK = request. querystring ("ck") time2 = trim (request. form ("time") QQ = trim (request. form ("QQ") IP = request. servervariables ("http_x_forwarded_for") 'records the IP addresses accessed by the proxy server. Not all servers support if IP = "" Then IP = request. servervariables ("remote_addr") 'retrieves the IP address of the remote computer. end if connstr = "provider = Microsoft. jet. oledb.4.0; Data Source = "& server. mappath ("data. mdb ") &"; "set conn = server. createobject ("ADODB. connection ") set rs = server. createobject ("ADODB. recordset ") Conn. open connstrif ck = 1 then if massege <> "" Then SQL = "insert into [logbb] ([QQ], [IP], [time]) values ('"& QQ &"', '"& IP &"', '"& time1 &"') "end if ck = 2 then SQL =" delete from [logbb where [time] = '"& time2 &"' "end if ck = 3 then SQL =" Update [logbb] Set [QQ] = '"& QQ &"', [time] = '"& time1 &"' "end if RS. open SQL, Conn, 3, 3 response. write ("flag = 1") set rs = nothingset conn = nothing %>

ASP write cookie

<% @ Language = "VBScript" @ codePage = "936" %> <% option explicit 'This statement declares response before outputting any data. contenttype = "text/html" dim name, QQ, emaill, fromresponse. cookies ("user") ("name") = name'user is a cookie group, and name is the key value of this group.
<% @ Language = "VBScript" @ codePage = "936" %> <% option explicitresponse. contenttype = "text/XML" ''' continue to stage xmldim webcookie, keyresponse. write ("<cookie>") for each webcookie in request. cookies if request. cookies (webcookies ). haskeys then for each key in request. cookies (webcookie) response. write ("<user" & Key & "= '" & request. cookies (webcookie) (key) & "'/>") Next end if nextresponse. write ("</cookie>") ''' hashes 'cookie is a powerful tool for web development. %>

Response. cookies ("user") ("QQ") = qqresponse. cookies ("user") ("email") = emaillresponse. cookies ("user") ("from") = fromresponse. cookies ("user "). expires = "July 20,201 0" 'the important attribute is the survival date when the cookie is not manually deleted. %>

ASP read cookie

<% @ Language = "VBScript" @ codePage = "936" %> <% option explicitresponse. contenttype = "text/XML" ''' continue to stage xmldim webcookie, keyresponse. write ("<cookie>") for each webcookie in request. cookies if request. cookies (webcookies ). haskeys then for each key in request. cookies (webcookie) response. write ("<user" & Key & "= '" & request. cookies (webcookie) (key) & "'/>") Next end if nextresponse. write ("</cookie>") ''' hashes 'cookie is a powerful tool for web development. %>

ASP read/write notepad is a simple counter

<% @ Language = "VBScript" @ codePage = "936" %> <% option explicitresponse. contenttype = "text/XML" response. expires = 0dim FS, txt, counter_file, todayc, yestodayc, highc, mdate, svaedate, hdate, webcookie, keymdate = right (date (), 2) application. the lock 'application object is used to save the shared information of all users. Its method is lock. Unlock is commonly used to set FS = server. createobject ("scripting. fileSystemObject ") counter_file = server. mappath ("count.txt ")''''''''''''''''''''''''' ''' Set TXT = FS. opentextfile (counter_file) Application ("tcounter") = TXT. readlinetodayc = int (txt. readline) yestodayc = int (txt. readline) highc = int (txt. readline) svaedate = TXT. readlinehdate = TXT. readlinetxt. close ''' read notepad ''' if isempty (session ("conn ")) then application ("tcounter") = Application ("tcounter") + 1if svaedate <> mdate then if todayc> highc then highc = todayc hdate = d Ateadd ("D",-1, date ()) end if yestodayc = todayc = 1 else todayc = todayc + 1end if ''''''''''''''''''''''''' ''' set TXT = FS. opentextfile (counter_file, 2, true) TXT. writeline (Application ("tcounter") TXT. writeline (todayc) TXT. writeline (yestodayc) TXT. writeline (highc) TXT. writeline (mdate) TXT. writeline (hdate) TXT. close ''' write notepad ''' end if set TXT = nothingset FS = nothingapplica Tion. unlocksession ("conn") = true '--------------- output pig header document ------------- response. Write ("<? XML version = '1. 0' encoding = 'gb2312 '?> <Count Tc = '"& todayc &" 'yc =' "& yestodayc &" 'hc = '"& highc &" 'hd =' "& (hdate) & "'tcount = '" & Application ("tcounter") & "'/>") %>

The following is playing in flash to complete these need to pay attention to the garbled because I do not know why the computer can not use UTF-8 so I had to use gb2312 ha, so every time in the flash to read or send data system. usecode = true; in this way, the downsides of writing are garbled characters when watching in an operating system that is not Chinese .... And UTF-8 will not have such a situation, hehe everything is advantageous also has drawbacks, of course, UTF-8 is whether it is a Chinese character or an English letter are stored in two bytes

As for UTF-8 usage, all ASP files are saved as UTF-8 formats, and all page declarations are 65001 XML declarations that are UTF-8 in flash and do not use system. usecode = true

Flash reads ASP data:
VaR bookxml: XML;
Bookxml. Load ("book. asp? Page = "+ Page +" & Rand = "+ math. Random ());
Haha, maybe it's strange how one sentence is actually a sentence, because the XML file is parsed, the page number is determined by the page above. You can set the page parameter on the page number button."& Rand =" + math. Random ()It is designed to prevent read cache from being more detailed.

Flash sends data:

Submit_btn.onrelease = function () {status_txt.text = "submitting data .. Please wait... "; Bsend_mc. _ visible = true; var send_lv: loadvars = new loadvars (); var result_lv: loadvars = new loadvars (); result_lv.onload = function (SUCCESS) {If (SUCCESS) {If (this. flag = 1) {status_txt.text = "sent successfully";} else {status_txt.text = "failed to send! ";}} Else {status_txt.text =" connection failed ";} bsend_mc. _ visible = false ;}; send_lv.title = success; send_lv.qq = qq_txt.text; send_lv.name = name_txt.text; success = success; send_lv.from = from_txt.text; send_lv.ck = 1; // This is for ASP to identify which SQL query should be executed send_lv.sendandload ("dbook. asp? Rand = "+ math. random (), result_lv, "Post "); ///////// ++ ++}

To achieve the effect of refreshing the image, you should add the statement that calls the page on which the read database is loaded after status_txt.text = "sent successfully .........

Of course, there must be a lot of imperfections. Please criticize and correct them more ......

If you get something from it, I am very pleased ......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.