ASP and ActiveX control interactively fight

xiaoxiao2021-03-06  36

ASP and ActiveX control interactively combat (2)

tornado

Keywords: ASP, ActiveX control, digital signature, security

Let's take a look at how to get data from the server and pass it to the ActiveX control.

1) Use parameters binding when initialization

2) Get data at runtime

Open VB6, create a new ActiveX control project.

Engineering Name: FOCX, User Control Name: UC2

For convenience, we use the ActiveX Control Interface Wizard ..., Menu -> Add,> Explorer -> VB 6 ActiveX Control Interface Wizard. OK.

Open ActiveX Control Interface Wizard, Next Members choose Text, next step until completion. There will be some unwanted, delete, and

'note! Don't delete or modify the following is commented!

'MappingInfo = txtinfo, txtinfo, -1, text

Public property get getInfo () AS STRING

GetInfo = txtinfo.text

End Property

Public property let getinfo (Byval new_getinfo as string)

TXTINFO.TEXT () = new_getinfo

PropertyChanged "getInfo"

End Property

Private submmand1_click ()

Label2.caption = getInfo ()

End Sub

'Load the attribute value from the memory

Private sub UserControl_readproperties (Propbag As PropertybAg): PRIVATE SUB UserControl

Txtinfo.text = propbag.readproperty ("getInfo", "text1")

End Sub

'Write the attribute value to the memory

Private sub UserControl_WriteProperties (Propbag As Propertybag)

Call Propbag.writeProperty ("getInfo", txtinfo.text, "text1")

End Sub

Compiled into an OCX control. Run the generated test page. Default is Text1

How do I pass the server's data to OCX?

Using Microsoft ActiveX Control Pad tools can be easily found.

Use this tool to open the test page.

Menu -> Edit-> Edit ActiveX Control, huh, open a visual interface.

I saw it, there is a property box, we can set it, the code after the completion is as follows:

new page </ title></p> <p></ HEAD></p> <p><Body></p> <p><Object id = "getClient" width = 507 height = 440</p> <p>ClassID = "CLSID: 890D1028-298B-45CF-9A64-6ED5A5BACBC9"</p> <p>Codebase = "http://localhost/xml/focx.ocx"></p> <p><Param name = "_ extentX" value = "13414"> <param name = "_ exceTy" value = "11642"></p> <p><Param name = "getInfo" value = "This is the information of the client reader"></p> <p></ Object></p> <p></ Body></p> <p></ Html></p> <p>Increase the ID, ID is the sign we use. There is also our property GetInfo, we also set the initial value.</p> <p>Ok, run.</p> <p>There is a value we set in text "This is the information of the client reader" obtained by OCX. "</p> <p>We change the page on the top of the page to the ASP, see the code:</p> <p><Html></p> <p><HEAD></p> <p><Title> Tornado Test Page </ Title></p> <p></ HEAD></p> <p><Body></p> <p><%</p> <p>DIM Svalue</p> <p>Svalue = "This is the information of the client reader obtained by OCX"</p> <p>%></p> <p><Object id = "getClient" width = 507 height = 440</p> <p>ClassID = "CLSID: 56DFCA88-F5B8-4879-853B-97FE504423FD"</p> <p>Codebase = "http://localhost/xml/focx.ocx"></p> <p><Param name = "_ extentX" value = "13414"></p> <p><Param name = "_ excenty" value = "11642"></p> <p><Param name = "getInfo" value = "<% = svalue%>">></p> <p></ Object></p> <p></ Body></p> <p></ Html></p> <p>OK, run</p> <p>Let's take a look at the second situation</p> <p>Get data at runtime</p> <p><Html></p> <p><HEAD></p> <p><Title> Tornado Test Page </ Title></p> <p><%</p> <p>DIM Svalue</p> <p>Svalue = "This is the information of the client reader obtained by OCX"</p> <p>%></p> <p><Script id = client, = javascript></p> <p><! -</p> <p>Function button1_onclick ()</p> <p>{</p> <p>GetClient.getInfo = '<% = svalue%>';</p> <p>}</p> <p>// -></p> <p></ Script></p> <p></ HEAD></p> <p><Body></p> <p><Object id = "getClient" width = 507 height = 440</p> <p>ClassID = "CLSID: 56DFCA88-F5B8-4879-853B-97FE504423FD"</p> <p>Codebase = "http://localhost/xml/focx.ocx"></p> <p><Param name = "_ extentX" value = "13414"></p> <p><Param name = "_ excenty" value = "11642"></p> <p></ Object></p> <p><Input ID = Button1 Type = Button Value = Button Name = Button1 Language = JavaScript οnclick = "Return Button1_Onclick ()> </ body></p> <p></ Html></p> <p>After running, click the button to see the effect.</p> <p>Problem: ActiveX control gets information about the client, how to pass to the server ??? A method is to get a value, use the GET, POST mode, which may be most common. Is there a better way? Can you get a request directly to the server directly to send a request directly?</p> <p>Open VB6, create a new ActiveX control project. Engineering Name: FOCX, User Control Name: UC3 Add 1 button, 2 text box code as follows:</p> <p>Option expedition</p> <p>PRIVATE SUB Command1_Click () 'Write some differences of strings and numbers Some differences' Use asyncRead to send your request UserControl.asyncRead "http: //yang/xml/activex.asp? S1 =" & text1.text "" , vbasynctypebytearray usercontrol.asyncread "http: //yang/xml/activex.asp? s1 =" & text1.text, vbasyncTypebyteaRay End Sub</p> <p>'AsyncReadComplete events are used to accept and analyze from ASP page. 'When the container just completes an asynchronous reading request, the value in the' asyncprop specifies the completed asynchronous data read request, 'It matches the data in the previous ASYNCREAD method call. The error handling code should be included during the 'AsyncReadcomplete event process because the error status will terminate the download. 'If this happens, an error will occur when accessing the Value property of the AsyncProperty object. Private Sub UserControl_AsyncReadComplete (AsyncProp As AsyncProperty) On Error GoTo errhandle Text2.Text = ByteArrayToString (AsyncProp.Value) errhandle: Err.Raise 601, "asynchronous read error occurred", Err.Description End Sub 'converts an array of bytes into String PUBLIC FUNCTION BYTEARRAYTOSTRING (Bytarray () AS BYTE) AS STRING DIM SANS AS STRING SANS = STRCONV (Bytarray, Vbunicode) ByteaRrayTString = Sans End Function</p> <p>Let's take a look at http: //yang/xml/activex.asp <% DIM STR = Request ("S1") if str = "name" the response.write ("Tornade") elseif str = "agn" Then Response.write ("26") Else Response.write ("No Information Returns") End IF%> Very simple, use the request accept parameters, response returns.</p> <p>This example can be further processed to pass the server name to the control in a property. For example: <param name = "servername" value = "192.168.0.1"> You can use it in the program, you can use, such as userControl.asyncread "http://192.168.0.1/xml/activex.asp?s1= "& Text1.Text &", VBASYNCTYPEBYTEARRAY then can be flexible in the program.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-62354.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="62354" 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.032</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 = 'vvskrNLMYXgpfg43_2BWJ4yl35y2KQfm6ytOWwHxkPYZBZO_2FGQfovdE7c5_2BK5Aq2H30GzsbFjp_2B_2B0oBqg2vZ3o9g_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>