-
Notifications
You must be signed in to change notification settings - Fork 21
/
frmPluginAutoUpdate.frm
818 lines (694 loc) · 27.6 KB
/
frmPluginAutoUpdate.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmPluginAutoUpdate
Caption = "Plugin AutoUpdate"
ClientHeight = 5490
ClientLeft = 60
ClientTop = 510
ClientWidth = 7635
Icon = "frmPluginAutoUpdate.frx":0000
LinkTopic = "Form1"
ScaleHeight = 5490
ScaleWidth = 7635
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdClose
Cancel = -1 'True
Caption = "&Close"
Height = 375
Left = 6480
TabIndex = 3
Top = 5040
Width = 1095
End
Begin VB.CommandButton cmdDownload
Caption = "&Download"
Enabled = 0 'False
Height = 375
Left = 5280
TabIndex = 2
Top = 5040
Width = 1095
End
Begin VB.CommandButton cmdRefresh
Caption = "&Refresh"
Height = 375
Left = 4080
TabIndex = 1
Top = 5040
Width = 1095
End
Begin VB.Frame fraPlugins
Height = 4815
Left = 120
TabIndex = 0
Top = 120
Width = 7455
Begin VB.Frame fraDownloadMessage
BackColor = &H00000000&
BorderStyle = 0 'None
Height = 1335
Left = 1560
TabIndex = 5
Top = 1680
Width = 4455
Begin MSComctlLib.ProgressBar pbrStatus
Height = 135
Left = 1680
TabIndex = 7
Top = 1080
Width = 1095
_ExtentX = 1931
_ExtentY = 238
_Version = 393216
BorderStyle = 1
Appearance = 0
Scrolling = 1
End
Begin VB.Label lblDownloadText
Alignment = 2 'Center
BackColor = &H00FFFFFF&
Caption = "Downloading ... Please wait!"
Height = 255
Left = 120
TabIndex = 6
Top = 480
Width = 4215
End
Begin VB.Shape shpStatus
BackStyle = 1 'Opaque
Height = 495
Left = 0
Top = 360
Width = 4455
End
Begin VB.Shape shpRedLine
BackColor = &H00000080&
BackStyle = 1 'Opaque
Height = 735
Left = 0
Top = 240
Width = 4455
End
End
Begin MSWinsockLib.Winsock wskPluginDownload
Index = 0
Left = 6240
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemoteHost = "www.computec.ch"
RemotePort = 80
End
Begin MSWinsockLib.Winsock wskDownload
Index = 0
Left = 6720
Top = 0
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemoteHost = "www.computec.ch"
RemotePort = 80
End
Begin MSComctlLib.ListView lsvPlugins
Height = 4455
Left = 120
TabIndex = 4
Top = 240
Width = 7215
_ExtentX = 12726
_ExtentY = 7858
SortKey = 1
View = 3
LabelEdit = 1
Sorted = -1 'True
LabelWrap = -1 'True
HideSelection = -1 'True
AllowReorder = -1 'True
Checkboxes = -1 'True
FullRowSelect = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
Enabled = 0 'False
NumItems = 5
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "ID"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "Name"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Text = "Installed"
Object.Width = 4304
EndProperty
BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 3
Text = "Available"
Object.Width = 4304
EndProperty
BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 4
Text = "Action"
Object.Width = 4304
EndProperty
End
End
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu mnuFileCloseItem
Caption = "&Close"
Shortcut = ^Q
End
End
Begin VB.Menu mnuPlugins
Caption = "&Plugins"
Begin VB.Menu mnuPluginsRefreshItem
Caption = "&Refresh"
Shortcut = {F5}
End
Begin VB.Menu mnuPluginsSeparator1
Caption = "-"
End
Begin VB.Menu mnuPluginsSearchPluginItem
Caption = "Sear&ch plugin"
Enabled = 0 'False
Shortcut = ^F
End
Begin VB.Menu mnuPluginsFindNextItem
Caption = "&Find next"
Enabled = 0 'False
Shortcut = {F3}
End
Begin VB.Menu mnuPluginsSeparator2
Caption = "-"
End
Begin VB.Menu mnuPluginsSelectAllItem
Caption = "Select &all"
Enabled = 0 'False
Shortcut = ^A
End
Begin VB.Menu mnuPluginsDeselectAllItem
Caption = "Dese&lect all"
Enabled = 0 'False
Shortcut = ^D
End
Begin VB.Menu mnuPluginsDownloadItem
Caption = "&Download"
Enabled = 0 'False
Shortcut = ^{F5}
End
Begin VB.Menu mnuPluginsSeparator4
Caption = "-"
End
Begin VB.Menu mnuPluginsShowItem
Caption = "&Show plugin entry in web browser"
Enabled = 0 'False
Shortcut = {F4}
End
End
Begin VB.Menu mnuHelp
Caption = "&Help"
Begin VB.Menu mnuHelpPluginAutoUpdateHelp
Caption = "&Plugin AutoUpdate Help"
Shortcut = {F1}
End
End
End
Attribute VB_Name = "frmPluginAutoUpdate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' ************************************************************************************
' * Developement History *
' * *
' * Version 4.0 2005-01-04 *
' * - Fixed a bug in the pluginslist routine. The first item was not checked because *
' * the checking started with 1 instead of 0. *
' ************************************************************************************
Dim strNewPluginFileName As String
Dim strSearchText As String
Private Sub cmdClose_Click()
WriteLogEntry "Closing the " & Me.Caption & " frame.", 6
Unload Me
End Sub
Private Sub cmdDownload_Click()
Dim i As Integer
Dim intNewAvailablePlugins As Integer
Dim Try As Integer
Dim intNewPluginID As Integer
Call FreezeFrame
Call ReadText("Downloading new plugins ... Please wait!")
fraDownloadMessage.Visible = True
intNewAvailablePlugins = lsvPlugins.ListItems.Count
For i = 1 To intNewAvailablePlugins
'Delete the last download response
LastResponse = vbNullString
'On Error Resume Next
Set lsvPlugins.SelectedItem = lsvPlugins.ListItems(i)
If lsvPlugins.SelectedItem.Checked = True Then
Try = 0
strNewPluginFileName = lsvPlugins.SelectedItem.SubItems(1)
intNewPluginID = lsvPlugins.SelectedItem.Text
lblDownloadText.Caption = "Downloading plugin id " & intNewPluginID & _
" (" & i & "/" & intNewAvailablePlugins & ")... Please wait!"
WriteLogEntry "Downloading plugin id " & intNewPluginID & ". Please wait!", 6
Call DownloadNewPlugin
'Wait a few moments for a successful connection
Do While wskPluginDownload(0).State = sckConnected
If Try < application_attack_timeout * 0.5 Then
frmMain.Pause 1
Try = Try + 1000
Else
WriteLogEntry "Downloading plugin id " & intNewPluginID & _
" timeout after " & application_attack_timeout & " milliseconds.", 3
Exit Do
End If
Loop
End If
SetProgress (100 / intNewAvailablePlugins) * i
Next i
lsvPlugins.ListItems.Clear
WriteLogEntry "Plugin AutoUpdate complete. Ready!", 6
Call ReadText("New plugins has been installed and are now ready to use.")
Call ReleaseFrame
MsgBox "Your local ATK plugin repository has been updated." & vbNewLine & vbNewLine & _
"You are now able to run the latest ATK checks.", _
vbOKOnly, "Attack Tool Kit Plugin AutoUpdate finished"
Unload Me
End Sub
Private Sub cmdRefresh_Click()
Call FreezeFrame
SetProgress 0
WriteLogEntry "Plugin AutoUpdate generate available plugin list. Please wait!", 6
Call ReadText("Refreshing the list of available plugins.")
Call GenerateActualATKPluginsList
'Delete the last response
LastResponse = vbNullString
SetProgress 50
Me.Caption = "Plugin AutoUpdate - " & application_plugin_download_url
Call DownloadNewPluginsList
WriteLogEntry "Plugin AutoUpdate available list download complete. Ready!", 6
SetProgress 100
Call ReadText("The list of available plugins has been refreshed.")
Call ReleaseFrame
End Sub
Private Sub Form_Activate()
If Me.WindowState = vbMinimized Then
Me.WindowState = vbNormal
End If
End Sub
Private Sub Form_Load()
Call cmdRefresh_Click
End Sub
Private Sub DownloadNewPlugin()
Dim strPluginDownloadRequestFileName As String
Dim Try As Integer
strPluginDownloadRequestFileName = Replace(application_plugin_download_url & strNewPluginFileName, " ", "%20")
wskPluginDownload(0).Close
wskPluginDownload(0).Connect GetDownloadHostname(), 80
'Wait a few moments for a successful connection
Do While wskPluginDownload(0).State <> sckConnected
If Try < application_attack_timeout * 0.5 Then
frmMain.Pause 1
Try = Try + 1000
Else
Exit Do
End If
Loop
If wskPluginDownload(0).State = 7 Then
'Send the request with its needed command and linefeeds
WriteLogEntry "Sending request for downloading plugin ...", 6
wskPluginDownload(0).SendData "GET " & strPluginDownloadRequestFileName & " HTTP/1.0" & vbNewLine & vbNewLine
End If
End Sub
Private Sub DownloadNewPluginsList()
Dim Try As Integer
wskDownload(0).Close
wskDownload(0).Connect GetDownloadHostname(), 80
'Wait a few moments for a successful connection
Do While wskDownload(0).State <> sckConnected
If Try < application_attack_timeout * 0.5 Then
frmMain.Pause 1
Try = Try + 1000
Else
Exit Do
End If
Loop
If wskDownload(0).State = 7 Then
'Send the request with its needed command and linefeeds
WriteLogEntry "Sending request for downloading new plugins list ...", 6
wskDownload(0).SendData "GET " & application_plugin_download_url & "pluginslist.txt HTTP/1.0" & vbNewLine & vbNewLine
Else
WriteLogEntry "No connection to the plugin repository server possible. Abording.", 3
MsgBox "There could no connection to the plugin repository server " & vbNewLine & _
wskDownload(0).RemoteHost & _
" be established." & vbNewLine & vbNewLine & _
"Please check the network settings and try again.", _
vbOKOnly, "Attack Tool Kit Plugin AutoUpdate connection error"
Unload Me
End If
End Sub
Private Sub LoadNewPlugins()
Dim m As Integer
Dim n As Integer
Dim List As ListItem 'Needed for the listview handling
Dim intFreeFile1 As Integer
Dim intFreeFile2 As Integer
Dim strTempStringNew As String
Dim strTempStringAvailable As String
Dim ArrayNew() As String
Dim ArrayAvailable() As String
Dim intArrayNewItems As Integer
Dim intArrayAvailableItems As Integer
Dim TempArrayNew() As String
Dim TempArrayAvailable() As String
Dim bolPluginAvailable As Boolean
SetProgress 0
lsvPlugins.ListItems.Clear
'Put the file data into the arrays
If (Dir$(application_plugin_directory & "/newpluginslist.txt", 16) <> "") Then
WriteLogEntry "Generate the file containing the new plugins...", 6
intFreeFile1 = FreeFile
Open application_plugin_directory & "/newpluginslist.txt" For Input As #intFreeFile1
strTempStringNew = Input(LOF(intFreeFile1), #intFreeFile1)
Close
ArrayNew() = Split(strTempStringNew, vbNewLine, , vbBinaryCompare)
intArrayNewItems = UBound(ArrayNew)
Else
WriteLogEntry "Could not create the file containing the new plugins...", 2
End If
If (Dir$(application_plugin_directory & "/pluginslist.txt", 16) <> "") Then
WriteLogEntry "Generate the file containing the locally installed plugins", 6
intFreeFile2 = FreeFile
Open application_plugin_directory & "/pluginslist.txt" For Input As #intFreeFile2
strTempStringAvailable = Input(LOF(intFreeFile2), #intFreeFile2)
Close
ArrayAvailable() = Split(strTempStringAvailable, vbNewLine, , vbBinaryCompare)
intArrayAvailableItems = UBound(ArrayAvailable)
If intArrayAvailableItems < 2 Then
ArrayAvailable(1) = vbNullString
End If
Else
WriteLogEntry "Could not create the file containing the locally installed plugins.", 2
End If
WriteLogEntry "Comparing the local and remote plugin repository...", 6
For m = 0 To intArrayNewItems
If InStrB(1, ArrayNew(m), ";", vbBinaryCompare) Then
'Split the data to be written
TempArrayNew = Split(ArrayNew(m), ";")
For n = 0 To intArrayAvailableItems
If InStrB(1, ArrayAvailable(n), ";", vbBinaryCompare) Then
'Split the data to be written
TempArrayAvailable = Split(ArrayAvailable(n), ";")
bolPluginAvailable = False
If TempArrayAvailable(0) = TempArrayNew(0) Then
bolPluginAvailable = True
If TempArrayAvailable(2) <> TempArrayNew(2) Then
Set List = lsvPlugins.ListItems.Add(, , TempArrayAvailable(0))
List.SubItems(1) = TempArrayAvailable(1)
List.SubItems(2) = TempArrayAvailable(2) & " (" & TempArrayAvailable(3) & ")"
List.SubItems(3) = TempArrayNew(2) & " (" & TempArrayNew(3) & ")"
List.SubItems(4) = "Update (" & TempArrayNew(4) & " bytes)"
End If
Exit For
End If
End If
Next n
'Write the plugin if the plugin is new
If bolPluginAvailable = False Then
Set List = lsvPlugins.ListItems.Add(, , TempArrayNew(0))
List.SubItems(1) = TempArrayNew(1)
List.SubItems(2) = "N/A"
List.SubItems(3) = TempArrayNew(2) & " (" & TempArrayNew(3) & ")"
List.SubItems(4) = "Install (" & TempArrayNew(4) & " bytes)"
End If
End If
SetProgress (100 / intArrayNewItems) * m
Next m
fraPlugins.Caption = lsvPlugins.ListItems.Count & " new plugins are available"
'Set the right column width
LVColumnWidth lsvPlugins
SetProgress 100
If lsvPlugins.ListItems.Count = 0 Then
WriteLogEntry "No new plugins are available for download.", 5
MsgBox "No new plugins available.", _
vbOKOnly, "Attack Tool Kit Plugin AutoUpdate information"
Unload Me
End If
End Sub
Private Sub Form_Resize()
If Me.WindowState <> vbMinimized Then
'Prevent zu small windows in height
If Me.Height < 5000 Then
Me.Height = 5000
End If
'Prevent zu small windows in width
If Me.Width < 6000 Then
Me.Width = 6000
End If
fraPlugins.Height = Me.Height - 1460
lsvPlugins.Height = fraPlugins.Height - 360
fraPlugins.Width = Me.Width - 360
lsvPlugins.Width = fraPlugins.Width - 240
cmdClose.Left = fraPlugins.Width - 980
cmdDownload.Left = cmdClose.Left - cmdClose.Width - 120
cmdRefresh.Left = cmdDownload.Left - cmdDownload.Width - 120
cmdClose.Top = Me.Height - 1200
cmdDownload.Top = cmdClose.Top
cmdRefresh.Top = cmdClose.Top
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
WriteLogEntry "Unload the " & Me.Caption, 6
Set frmPluginAutoUpdate = Nothing
End Sub
Private Sub lsvPlugins_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
Call ListViewColumnReorder(frmPluginAutoUpdate.lsvPlugins, ColumnHeader)
End Sub
Private Sub lsvPlugins_DblClick()
If lsvPlugins.ListItems.Count Then
Dim WebSiteURL As String
WebSiteURL = application_plugin_download_url & lsvPlugins.SelectedItem.SubItems(1) & ".html"
'Load the project web site
WriteLogEntry "Loading the plugin website " & WebSiteURL, 6
Call ShellExecute(Me.hwnd, "Open", WebSiteURL, "", App.Path, 1)
Else
MsgBox "No new plugins available." & vbNewLine & vbNewLine & _
"Please hit the reload button to refresh the list of loadable new plugins.", _
vbOKOnly, "Attack Tool Kit Plugin AutoUpdate error"
Call cmdRefresh_Click
End If
End Sub
Private Sub lsvPlugins_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
'Show context menu if 2nd mouse button is pressed
If Button = vbRightButton Then
PopupMenu mnuPlugins
End If
End Sub
Private Sub mnuFileCloseItem_Click()
Call cmdClose_Click
End Sub
Private Sub mnuHelpPluginAutoUpdateHelp_Click()
Call OpenOnlineHelp("plugin_autoupdate")
End Sub
Private Sub mnuPluginsDeselectAllItem_Click()
Dim i As Integer
'Deselect all loadable plugins
For i = 1 To lsvPlugins.ListItems.Count
lsvPlugins.ListItems.Item(i).Checked = False
Next i
End Sub
Private Sub mnuPluginsDownloadItem_Click()
Call cmdDownload_Click
End Sub
Private Sub mnuPluginsFindNextItem_Click()
Call SearchPlugin
End Sub
Private Sub mnuPluginsRefreshItem_Click()
Call cmdRefresh_Click
End Sub
Private Sub mnuPluginsSearchPluginItem_Click()
'Define a default search string if this is the first search
If LenB(strSearchText) = 0 Then
strSearchText = "Apache prior 2.0"
End If
'Ask for the search string
strSearchText = InputBox("Please enter string you are searching for. " & _
"(e.g. Microsoft, Apache, Sendmail).", _
"Plugin AutoUpdate plugin search", strSearchText)
'Start the search
Call SearchPlugin
End Sub
Private Sub mnuPluginsSelectAllItem_Click()
Dim i As Integer 'This i is used for the counters
Dim intShownPlugins As Integer 'How many plugins are loaded
intShownPlugins = lsvPlugins.ListItems.Count
'Check if there is one or more checks activated for the audit
For i = 1 To intShownPlugins
lsvPlugins.ListItems.Item(i).Checked = True
Next i
End Sub
Private Sub SelectNewPlugins()
Dim i As Integer 'This i is used for the counters
Dim intShownPlugins As Integer 'How many plugins are loaded
intShownPlugins = lsvPlugins.ListItems.Count
'Check if there is one or more checks activated for the audit
For i = 1 To intShownPlugins
If Not lsvPlugins.ListItems.Item(i).SubItems(2) = lsvPlugins.ListItems.Item(i).SubItems(3) Then
lsvPlugins.ListItems.Item(i).Checked = True
End If
Next i
End Sub
Private Sub mnuPluginsShowItem_Click()
Call lsvPlugins_DblClick
End Sub
Private Sub wskDownload_Close(Index As Integer)
Call WriteNewPluginsListToFile
Call LoadNewPlugins
Call SelectNewPlugins
wskDownload(0).Close
End Sub
Private Sub WriteNewPluginsListToFile()
Dim intFreeFile As Integer
intFreeFile = FreeFile
'Strip the http header
LastResponse = Mid$(LastResponse, InStr(1, LastResponse, vbNewLine & vbNewLine) + 4)
'Replace the Linefeeds
If InStrB(1, LastResponse, vbLf, vbBinaryCompare) Then
LastResponse = Replace$(LastResponse, vbLf, vbNewLine)
End If
On Error Resume Next ' Needed if there are no write permissions
Open application_plugin_directory & "\newpluginslist.txt" For Output As #intFreeFile
Print #intFreeFile, LastResponse
Close
End Sub
Private Sub WriteNewPluginToFile()
Dim intFreeFile As Integer
intFreeFile = FreeFile
'Strip the http header
LastResponse = Mid$(LastResponse, InStr(1, LastResponse, vbNewLine & vbNewLine) + 4)
'Replace the Linefeeds
If InStrB(1, LastResponse, vbLf, vbBinaryCompare) Then
LastResponse = Replace$(LastResponse, vbLf, vbNewLine)
End If
On Error Resume Next ' Needed if there are no write permissions
Open application_plugin_directory & "\" & strNewPluginFileName For Output As #intFreeFile
Print #intFreeFile, LastResponse
Close
End Sub
Private Sub wskDownload_DataArrival(Index As Integer, ByVal bytesTotal As Long)
'Here is the incoming data cached
Dim DataStr As String
'Read the incoming data and write it to DataStr$
Call wskDownload(0).GetData(DataStr$, vbString)
LastResponse = LastResponse & DataStr
End Sub
Private Sub wskDownload_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
WriteLogEntry "WinSock Error: [" & Number & "] " & Description, 1
Call wskDownload_Close(0)
End Sub
Private Function GetDownloadHostname() As String
Dim strTempArray() As String
Dim strPluginsDownloadURLTemp As String
strPluginsDownloadURLTemp = application_plugin_download_url
'Strip http://
If InStr(1, strPluginsDownloadURLTemp, "http://") Then
strPluginsDownloadURLTemp = Mid$(strPluginsDownloadURLTemp, 8, Len(strPluginsDownloadURLTemp))
End If
'Strip all slashes from the URL
If InStr(1, strPluginsDownloadURLTemp, "/") Then
strTempArray = Split(strPluginsDownloadURLTemp, "/")
strPluginsDownloadURLTemp = strTempArray(0)
End If
'Strip all back slashes from the URL
If InStr(1, strPluginsDownloadURLTemp, "\") Then
strTempArray = Split(strPluginsDownloadURLTemp, "\")
strPluginsDownloadURLTemp = strTempArray(0)
End If
GetDownloadHostname = strPluginsDownloadURLTemp
End Function
Private Sub wskPluginDownload_Close(Index As Integer)
Call WriteNewPluginToFile
wskPluginDownload(0).Close
End Sub
Private Sub wskPluginDownload_DataArrival(Index As Integer, ByVal bytesTotal As Long)
'Here is the incoming data cached
Dim DataStr As String
'Read the incoming data and write it to DataStr$
Call wskPluginDownload(0).GetData(DataStr$, vbString)
LastResponse = LastResponse & DataStr
End Sub
Private Sub wskPluginDownload_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
WriteLogEntry "WinSock Error: [" & Number & "] " & Description, 1
Call wskPluginDownload_Close(0)
End Sub
Private Sub FreezeFrame()
fraDownloadMessage.Visible = True
Screen.MousePointer = 13
lsvPlugins.Enabled = False
cmdRefresh.Enabled = False
cmdDownload.Enabled = False
mnuPluginsSearchPluginItem.Enabled = False
mnuPluginsFindNextItem.Enabled = False
mnuPluginsRefreshItem.Enabled = False
mnuPluginsDeselectAllItem.Enabled = False
mnuPluginsSelectAllItem.Enabled = False
mnuPluginsShowItem.Enabled = False
mnuPluginsDownloadItem.Enabled = False
DoEvents
End Sub
Private Sub ReleaseFrame()
fraDownloadMessage.Visible = False
Screen.MousePointer = 0
lsvPlugins.Enabled = True
cmdRefresh.Enabled = True
cmdDownload.Enabled = True
mnuPluginsSearchPluginItem.Enabled = True
mnuPluginsFindNextItem.Enabled = True
mnuPluginsRefreshItem.Enabled = True
mnuPluginsDeselectAllItem.Enabled = True
mnuPluginsSelectAllItem.Enabled = True
mnuPluginsShowItem.Enabled = True
mnuPluginsDownloadItem.Enabled = True
End Sub
Public Sub SetProgress(ByRef intValue As Integer)
'Prevent too large values (this is just a nasty workaround!)
If intValue > 100 Then
intValue = 100
End If
pbrStatus.Value = intValue
frmMain.StatusBar.Panels(2).Text = intValue & " %"
frmMain.pbrProgress.Value = intValue
End Sub
Private Sub SearchPlugin()
Dim intListItemStartPosition As Integer
Dim intListItemCount As Integer
Dim i As Integer
WriteLogEntry "Starting the search for the string " & strSearchText, 1
intListItemCount = lsvPlugins.ListItems.Count
If lsvPlugins.SelectedItem.Index < intListItemCount Then
intListItemStartPosition = lsvPlugins.SelectedItem.Index + 1
Else
intListItemStartPosition = 1
End If
For i = intListItemStartPosition To intListItemCount
If InStrB(1, _
LCase$(lsvPlugins.ListItems.Item(i).SubItems(1)), _
LCase$(strSearchText), vbBinaryCompare) Then
Set lsvPlugins.SelectedItem = lsvPlugins.ListItems(i)
lsvPlugins.SetFocus
lsvPlugins.SelectedItem.EnsureVisible
Exit For
End If
Next i
End Sub