ASP programming into the first step (13): Ad & Content Rot

xiaoxiao2021-03-06  30

Author: cnbruce posted from: 5D powerful multimedia ASP is not limited to acceptance and interactive display, the more is the use of ActiveX components more powerful Web applications.

What is the ActiveX component? How is it working? In fact, ActiveX Server Components is a file that exists on the web server. This file contains code that performs an item or a set of tasks, and component can perform public tasks so you don't have to create code of these tasks. A very image: Use the component directly using someone else's classic function. This procedure has been packaged.

How is the specific ActiveX component generated, how to get it? It is generally obtained by the following three paths: 1. After installing the IIS server, some built-in components that come into bring, such as the Database Access database connection component. 2. Get an optional component from a third-party developer, or free or charge, such as some upload assemblies (of course, there is now no component upload). 3, if you are a web program developer, you can use Visual Basic, Java, Visual C , COBOL and other programming languages ​​to write the ActiveX Server Component you need. This is the so-called ASP for COM (Component Object Model), COM development.

Of course, whether the third party is still developed, the system must be registered before use. However, these are later. What we need now is to understand some of the components that come with the ASP as soon as possible.

However, before using the built-in component, first detect the component support in your own machine. Quote a paragraph of online popular "Ajiang ASP Probes", save the following code as an ASP file for debugging.

1, Objcheck.asp

<% OPTION Explicit%> <% DIM filenamefilename = request.servervariables ("script_name")

DIM Objtotest (14, 4) Objtotest (0) = "mswc.adrotator" Objtotest (0, 1) = "advertising wheel" objtotest (1,0) = "mswc.contentrotator" Objtotest (1, 1) = "Content Wheel Diagram" Objtotest (2,0) = "mswc.browsertype" objtotest (2, 1) = "Browser Type Display Components" Objtotest (3, 0) = "Mswc.nextLink" Objtotest (4, 0 = "Mswc.tools" objtotest (5,0) = "mswc.status" objtotest (6,0) = "mswc.counters" Objtotest (7, 0) = "mswc.iislog" Objtotest (8, 0) = "Mswc.permissionchecker" objtotest (9, 0) = "microsoft.xmldom" objtotest (10, 0) = "iissample.contentrotator" objtotest (11,0) = "iissample.pagecounter" Objtotest (12, 0) = "scripting .Filesystemobject "objtotest (13, 0) =" adodb.connection "public isobj, Verobj, Testobj

DIM IFOR i = 0 to 13 on error resume next isobj = false verobj = "" Testobj = "" SET TESTOBJ = Server.createObject (Objtotest (i, 0)) IF isobject (Testobj) THEN ISOBJ = true verobj = testobj.version IF Verobj = "" "or isnull (Verobj) Then Verobj = Testobj.about End IF Objtotest (i, 2) = Isobj Objtotest (i, 3) = Verobjnext

sub ObjTest (strObj) on error resume next IsObj = false VerObj = "" TestObj = "" set TestObj = server.CreateObject (strObj) If IsObject (TestObj) then IsObj = True VerObj = TestObj.version if VerObj = "" or isnull (Verobj) THEN VEROBJ = Testobj.about end if End sub%> Object check </ title> <table border = "1" cellpadding = "0" cellspacing = "0" style = "border-collapse: _ collapse "bordercolor =" # cccccc "width = 80%> <tr align = center> <td width = 40%> Component name </ td> <td width = 40%> Related information </ td> </ tr> <% For i = 0 to 13%> <Tr> <TD> <% = Objtotest (i, 0) & "<font color = _ # 888888>" & objtotest (i, 1)%> </ font> </ td > <TD> <% if not objtotest (i, 2) Then response.write "<font color = red> does not support </ font>" Else Response.write "Support," & Left (Objtotest (i, 3), 22) END IF%> </ td> </ tr> <% next%> </ table> <form action = <% = filename%> method = post> <input type = text name = "classname" size = 40 > <Input Type = Submit Value = "OK"> </ form></p> <p><% DIM STRCLASSTRCLASS = TRIM (Request.form ("ClassName")) If STRCLASS <> "" ThenResponse.write "<br> The result of the component you specify:" DIM VEROBJ1 Objtest (STRCLASS) if not isobj Then Response. Write "<font color = red> Unfortunately, the service _" does not support "& strclass &" components! </ Font> "else if verobj =" "or isnull (verobj) Then Verobj1 =" Unable to get Component version "Else Verobj1 =" This component version is: "& Verobj end if response.write" <br> <font class = fonts> Congratulations! The service _ _ device supports "& strclass &" components. "& Verobj1 &" < / font> "END IFEND IF%> If you can run the ASP file, that is, you have IIS's web service. Since there is IIS, there is no accident, the components we have to learn today should believe should be supported. P.S. General Microsoft comes with the beginning of MSWC, and I also gave a Microsoft WC.</p> <p>1. Adrotator Components This component is often referred to as an advertisement wheel assembly, which is equivalent to establishing an advertising system that meets the standard function of the advertising domain. It has: Each time you access the ASP page, different ad content is displayed on the page; track the ability of a specific number of applications for specific ad and the ability to track the number of clients on your client.</p> <p>The working principle of the AD Rotator component is done by reading the AD Rotator program file, which includes information related to the location where the image file is displayed, as well as the different properties of each image. Below is a standard AD Rotator program file.</p> <p>1. Type TXT text, named myadrot.txt</p> <p>The first four lines of the code contain global settings for ads:</p> <p>1. Redirect points out that the advertisement will become the URL of its thermal connection. However, it is not directly jumping URL, which contains two parameters query strings: the URL of the specific ad homepage and the URL of the image file. These values ​​can be extracted in a Gourl.asp file, and Gourl.asp can also perform other processing works, such as tracking the number of ads, jumps to the received ad homepage. 2, width, height, border does not need to say, know that the connection of the picture is wide, high, and the frame size.</p> <p>"*" Represents a separate part of each of the four behaviors under the "*" number, and the details of each ad. Among them, representatives:</p> <p>1. Description of each ad contains the URL of the image file. 2, the home page URL of the advertisement (if the advertiser does not have the home page, the behavior "-", pointing out that the ad does not link). 3, alternative text of the image. 4. Specify the value of the display frequency with other pages with other pages.</p> <p>This file is a file created by the user. It is usually used to parse the script of the query string sent by the ADROTATOR object and redirect the user to the URL associated with the advertisement you click on the user. How do you apply this orientation file? 2. ADROTATOR.ASP This file is the most important thing to connect the MyAdrot.txt file and perform the information content in myAdrot.txt files. Very simple, two lines of code.</p> <p><% set myad = server.createObject ("mswc.adrotator")%> <% = myad.getadvertisement ("myadrot.txt")%></p> <p>"<% Set myad = server.createObject (" Mswc.adrotator "%>" learned a Server object, I believe it is a powerful method of the object, that is, CreateObject. He can be used to create an ActiveX component instance that has been registered to the server. That is, the reference component Mswc.Adrotator.</p> <p>"<% = Myad.getadvertisement (" MyAdrot.txt "%>" AD Rotator component supports the only way to support, it has only one parameter: the name of the Adrotator program file. Note that the path to the file is the relative to the current virtual directory The path, the physical path is not allowed. That is to say, the current adrotator.asp and myadrot.txt are in the same directory.</p> <p>Then perform the ASP file, and refresh multiple times, it will find that each advertisement is indeed a significant wheel. At this time, pay attention to the super connection address of the picture. such as:</p> <p>Gourl.asp? URL = UploadFiles / 20046492312734.GIF</p> <p>Obviously we also need to establish Gourl.asp, and extract the value of the URL parameter, and then jump to the URL address.</p> <p>3, Gourl.asp This page main function: extract the URL parameter value, jump to the ad homepage.</p> <p><% whatURL = Request.QueryString ("URL")%> <% response.redirect whatURL%></p> <p>The function is very simple. Of course, just said, this page can also do some other events: Tracking clients on the ads, such as the amount of the same URL address, can display the clicks of the website The number of times, then and the corresponding advertiser will take the corresponding fee ... Oh, in the early days, the actual click rate is required. Now I seem to have, as long as the advertisement is hanging, it is -_-!</p> <p>However, in general, the functionality of this component is this. You have multiple advertisers, and it is displayed separately, and it is also necessary to calculate the actual click rate, it is best to use the AD Rotator component. That is to say the situation is determined.</p> <p>Finally, the implementation of the component requires three files: redirect file, reference file, and process the steering file.</p> <p>Second, Content Rotator Components</p> <p>As the AD Rotator is an advertising wheel, the Content Rotator component is the content wheel. This component is like a simplified AD Rotator component, so its working principle is also: display of web content that is completed by reading plan files. The plan file is also: Content Schedule File.</p> <p>1. Type TXT text, named context.txt</p> <p>%% 3 // is Note <color = red> ASP programming introduction </ color> %% 4 // below Show Table <Table> <Tr> <TD> www.cnbruce.com </ td> </ Tr> </ table> %% 5 <a href="http://www.cnbruce.com"> CN-Bruce </a> This file is simpler than the scheduling file of the AD Rotator, only needs to be used. A list of each text string, a statement of two percentile (%%), plus.</p> <p>In order to set the ratio of each entry (determined that it appears in the return page), a number is added behind the double hundred semicolons. If followed by the double slash (/ /), it is expressed as the added annotation.</p> <p>Then, this information is completely displayed by the ASP page.</p> <p>2, showcontext.asp</p> <p><% Set mycontent = server.createObject ("mswc.contentrotator") Content = mycontent.choosecontent ("Context.txt") response.write content%></p> <p>"SET myContent = Server.createObject (" Mswc.contentrotator ", first establish contact with the Content Rotator component.</p> <p>"Content = mycontent.choosecontent (" context.txt ", indicating a method using the Content Rotator component: choosecontent, and assigns a value to the variable content, to the final output display result.</p> <p>3, Showall.asp The above page content is displayed by the ChooseContent method of the Content Rotator component. In addition, the component has a method: getAllContent. Examples are as follows:</p> <p><% Set mycontent = server.createObject ("mswc.contentrotator") content = mycontent.getAllContent ("Context.txt") response.write content%></p> <p>The result of the run will find that all contents of Context.txt are explained and the <HR> horizontal line is automatically added between the categories.</p> <p>Of course this method can be used on a special effect page such as a random picture.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-70867.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="70867" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.046</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = '1Yc_2Fq5JIg5qeD5TspUl57SE0KLXL_2BZhoEKOYLp31us2sNtH4CDpA9F7qIGnWYMFXWb9IPtx7WZC_2B3Ua7_2FBRK3Q_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>