-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDBBackup.hta
1171 lines (1006 loc) · 49.6 KB
/
DBBackup.hta
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
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html>
<title>MySQL Backup | GaP Solutions Pty. Ltd.</title>
<head>
<!-- <meta http-equiv="x-ua-compatible" content="ie=9"> -->
<HTA:APPLICATION
ID="MySQLBackup"
BORDER="thin"
BORDERSTYLE="normal"
CAPTION="yes"
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
WINDOWSTATE="window"
NAVIGATABLE="yes"
INNERBORDERS="no"
SCROLL="no"
APPLICATIONNAME="MySQL Backup"
SINGLEINSTANCE="no"
SYSMENU="yes"
SELECTION="no"
VERSION="2020.04.19" />
<!-- https://github.com/nathan026/MySQLBackup -->
<style>
BODY {
background-color: #333333;
font-family: Verdana;
font-size: 15px;
color: cbcbcb;
margin: 0;
}
a:visited {
color: Black;
text-decoration: none;
}
h1, h2, h3, h4, h5, h6 {
margin-bottom: 0.5;
}
div.Blanket_Div {
visibility:hidden;
Background:Black;
filter:alpha(opacity=80);
opacity:0.2;
z-index:9999;
height:100%;
width:100%;
position:absolute;
text-align:center;
line-height:600px;
}
div.UpdateBar_Div {
visibility: hidden;
z-index:9998;
background: #ffcc66;
color: Black;
font-size: 20px;
top: 0px;
text-align: center;
position: absolute;
width: 100%;
height: 30px;
}
div.Diag_Div {
visibility: hidden;
z-index:9997;
background: White;
color: Black;
font-size: 16px;
top: 0px;
text-align: center;
position: absolute;
width: 50%;
right: 10%;
height: 30px;
}
div.Header_Div {
height:10%;
background-color:#329f50;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
color: White;
overflow: hidden;
}
div.Info_Div {
background-color: #4a4a4a;
test-align: left;
left: 0px;
bottom: 8%;
position: absolute;
}
div.Footer_Div {
background-color:#1a1a1a;
color:#9f9f9f;
bottom:0px;
height:8%;
left:0px;
position:absolute;
text-align:left;
width:100%;
}
div.Version_Div {
background-color:#1a1a1a;
color:#9f9f9f;
bottom:0px;
height:8%;
right:0px;
position:absolute;
text-align:right;
width:50%;
}
div.SpeedTest_Div {
font-weight: bold;
top:0px;
height:8%;
right:0px;
position:absolute;
text-align:center;
width:10%;
}
</style>
<script language="VBScript">
window.resizeTo 500,550
window.moveTo (screen.Width - 500)/2, ((screen.Height - 550)/2)-20
On Error Resume Next
Dim fso, tempfile, tfolder, strMySQL, strSQLUser, strPassword, strSQLFile, strBackup, strMySQLdump, strMySQLcheck, strAppVer, loaded, http_obj, stream_obj, objShell, strUpdate
Dim strCommandLine, strHTA
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Set UAC = CreateObject("Shell.Application")
Set tfolder = fso.GetSpecialFolder(TemporaryFolder)
set http_obj = CreateObject("Microsoft.XMLHTTP")
set stream_obj = CreateObject("ADODB.Stream")
strSQLUser = tfolder & "\sqluser"
strTools = tfolder & "\sqlTools"
strSQLFile = tfolder & "\mysqldump.sql"
strBackup = tfolder & "\MySQL_Backup"
strAppVer = MySQLBackup.Version
strHTA = Self.location.pathname
strCommandLine = MySQLBackup.CommandLine
MySQLstate = "False"
ConnectorState = "False"
DotNetState = "Flase"
StoreNameState1 = "No Store Details Available"
eziscaleState = ""
eziscale45State = ""
eziposState = ""
objFileSerial = ""
Const TemporaryFolder = 2
Sub Window_OnLoad
AppVersion.InnerHTML = strAppVer
Set colIP = objWMIService.ExecQuery ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
Set colCOMPNAME = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem" )
For each objCOMPNAME in colCOMPNAME
CompName.innerHTML = objCOMPNAME.Name
next
On Error Resume Next
For each objitem in colIP
IP.innerHTML = Join(objitem.IPAddress, " . . . . ")
Exit For
Next
On Error Goto 0
If fso.FileExists("C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql.exe") Then
objShell.CurrentDirectory = "C:\Program Files\MySQL\MySQL Server 5.5\bin\"
strMySQL = "mysql.exe"
strMySQLadmin = "mysqladmin.exe"
strMySQLdump = "mysqldump.exe"
strMySQLcheck = "mysqlcheck.exe"
MySQLInstall = True
ElseIf fso.FileExists("C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin\mysql.exe") Then
objShell.CurrentDirectory = "C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin\"
strMySQL = "mysql.exe"
strMySQLadmin = "mysqladmin.exe"
strMySQLdump = "mysqldump.exe"
strMySQLcheck = "mysqlcheck.exe"
MySQLInstall = True
Else
strMySQL = "echo"
strMySQLadmin = "echo"
strMySQLdump = "echo"
strMySQLcheck = "echo"
document.getElementById("start").disabled=true
MsgBox "MySQL could not be found", , "Error!"
End If
setTimeout "CheckUpdate", 100, "VBScript"
call Password()
call ComponenetCheck()
call CheckMySQL1()
End Sub
Sub Password
Blanket_Div.style.visibility="visible"
strPassword = InputBox("Enter Password", MySQLBackup.applicationName, "")
Blanket_Div.style.visibility="hidden"
End Sub
Sub CheckMySQL1
IF strPassword = "" Then Exit Sub
Dim DNSResult
DB1Check.innerhtml = "--"
DB1Check.style.color = "Yellow"
On Error Resume Next
DNSResult = objShell.run (strMySQL & " --user=gap -p" & strPassword & " -h " & Host_IP.Value & " -e ""select '1';""", 0, True)
On Error Goto 0
Set objFile2 = fso.CreateTextFile(strTools)
strLine = " select * from (" & _
" SELECT case when value = 'True' then 'MasterTrue' else 'MasterFales' end FROM checkoutsettings WHERE section='General' AND KeyName='Master' AND (StoreID=(SELECT value FROM settings" & _
" WHERE section='General' AND KeyName='StoreID') OR StoreID=0) ORDER BY StoreID DESC LIMIT 1) as a" & _
" union" & _
" SELECT * from (" & _
" SELECT case when value <> '5' then 'SmallestDenominationWarning' else 'SmallestDenomination_5c' end FROM checkoutsettings WHERE section='Sales' AND KeyName='SmallestDenomination' AND Value<>'5' AND (StoreID=(SELECT value FROM settings" & _
" WHERE section='General' AND KeyName='StoreID') OR StoreID=0) ORDER BY StoreID DESC LIMIT 1) as b" & _
" union" & _
" SELECT case when size<1 THen 'InnoDBSizeWarning' else concat(Round(size, 2), 'GB_innoDB') end from (SELECT @@innodb_buffer_pool_size/1024/1024/1024 as size ) as c;"
objFile2.WriteLine strLine
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools) & " >" & DQ(strTools & "mastercheck"), 0, True
Set objMaster = fso.OpenTextFile (strTools & "mastercheck", 1)
Do Until objMaster.AtEndOfStream
strMaster = objMaster.ReadLine
IF (strMaster="MasterTrue") THEN
isMaster.innerHTML = "(Master)"
END IF
IF (strMaster="SmallestDenominationWarning") THEN
isDenomination.innerHTML = "Smallest Denomination Warning"
END IF
IF (strMaster="InnoDBSizeWarning") THEN
isBufferSize.innerHTML = "InnoDB Buffer Size Warning"
END IF
Loop
IF strMySQL = "echo" Then
DB1Check.innerhtml = "??"
DB1Check.style.color = "Orange"
ElseIf DNSResult = 0 Then
DB1Check.innerhtml = "OK"
DB1Check.style.color = "LightBlue"
Else
DB1Check.innerhtml = "FAIL"
DB1Check.style.color = "RED"
End If
End Sub
Sub CheckMySQL2
IF strPassword = "" Then Exit Sub
Dim DNSResult
DB2Check.innerhtml = "--"
DB2Check.style.color = "Yellow"
On Error Resume Next
DNSResult = objShell.run (strMySQL & " --user=gap -p" & strPassword & " -h " & Target_IP.Value & " -e ""select '1';""", 0, True)
On Error Goto 0
IF strMySQL = "echo" Then
DB2Check.innerhtml = "??"
DB2Check.style.color = "Orange"
ElseIF DNSResult = 0 Then
DB2Check.innerhtml = "OK"
DB2Check.style.color = "LightBlue"
Else
DB2Check.innerhtml = "FAIL"
DB2Check.style.color = "RED"
End If
End Sub
Sub start
IF strPassword = "" Then Exit Sub
Blanket_Div.style.visibility="visible"
Set objFile = fso.CreateTextFile(strSQLUser)
strLine = "GRANT USAGE ON *.* TO 'gap'@'localhost' IDENTIFIED BY '" & strPassword & "'; GRANT ALL PRIVILEGES ON *.* TO 'gap'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES;" & _
" GRANT USAGE ON *.* TO 'gap'@'%' IDENTIFIED BY '" & strPassword & "'; GRANT ALL PRIVILEGES ON *.* TO 'gap'@'%' WITH GRANT OPTION;" & _
" GRANT USAGE ON *.* TO 'gappde'@'localhost' IDENTIFIED BY 'gappde'; GRANT ALL PRIVILEGES ON *.* TO 'gappde'@'localhost' WITH GRANT OPTION;" & _
" SET PASSWORD FOR 'gappde'@'localhost' = OLD_PASSWORD('gappde'); FLUSH PRIVILEGES;" & _
" CREATE DATABASE IF NOT EXISTS " & Target_DB.Value & "; " & _
" SET GLOBAL max_allowed_packet=1073741824;"
objFile.WriteLine strLine
objFile.Close
If (mode(0).Checked) Or (safetybackup.Checked) Then ''BACKUP
If Not fso.FolderExists(strBackup) Then
fso.CreateFolder strBackup
End If
strBackupName = "MySQL_dump" & replace(date,"/","")
If Not safetybackup.Checked then '' Safety Backup Checked? Take Backup...
strBackupName = InputBox("Save backup as...", "Save As", "MySQL_dump" & replace(date,"/",""))
End If
IF Not strBackupName ="" Then
objShell.Run strMySQLdump &_
" --user=gap -p" & strPassword & " --host=" & Host_IP.Value &_
" --hex-blob=TRUE --force " & Host_DB.Value & " -r " & DQ(strBackup & "\" & strBackupName & ".sql"), 0, True
If Not safetybackup.Checked then '' Safety Backup Checked? Take Backup...
MsgBox "Backup Complete!", , "Complete!"
UAC.Open strBackup
End If
End If
End If
If mode(1).Checked Then ''RESTORE
If fLocation.Value ="" Then
MsgBox "No File Selected!", , "Error!"
Else
objShell.Run "cmd /C " & strMySQL & " --user=root -proot -h " & Target_IP.Value & " < " & DQ(strSQLUser), 0, True
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -h " & Target_IP.Value & " --database=" & Target_DB.Value & " < " & DQ(fLocation.Value), 0, True
MsgBox "Restore Complete!", , "Complete!"
End If
End If
If mode(2).Checked Then ''MIGRATE
objShell.Run strMySQLdump & " --user=gap -p" & strPassword & " -h " & Host_IP.Value & " " & Host_DB.Value & " -f -r " & DQ(strSQLFile), 0, True
objShell.Run "cmd /C " & strMySQL & " --user=root -proot -h " & Target_IP.Value & " < " & DQ(strSQLUser), 0, True
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -h " & Target_IP.Value & " " & Target_DB.Value & " < " & DQ(strSQLFile), 0, True
MsgBox "Migration Complete!", , "Complete!"
End If
If mode(3).Checked Then ''CHECK + TOOLS
call Tools()
End If
Blanket_Div.style.visibility="Hidden"
End Sub
Sub CheckUpdate ''CHECK FOR UPDATES
Dim lenLatestVer, strCurrentVer, strLatestver
Checking.style.visibility="Visible"
strCurrentVer = Split( MySQLBackup.Version )(0)
strUpdate = LEFT(TextFromHTML( "https://webreports.gapsolutions.com.au/version.txt?noone=" & timer ), 500)
''strUpdate = LEFT(TextFromHTML( "https://raw.githubusercontent.com/nathan026/MySQLBackup/master/version.txt?noone=" & timer ), 500)
strLatestVer = LEFT(strUpdate,10)
If (Replace(strLatestver,".","") > Replace(strCurrentVer,".","")) Then
call UpdateNotification()
End If
Checking.style.visibility="Hidden"
End Sub
Sub Help
Blanket_Div.style.visibility="Visible"
result = msgbox(" Your Version: " & MySQLBackup.Version & vbCrLf &_
"Latest Version: " & strUpdate & "..." & vbCrLf & vbCrLf & cvCrLf & "Do you want to open the user manual?", vbYesNo, "Help!")
Select Case result
Case vbYes
objShell.run("https://docs.google.com/document/d/18HCIYXgQLZNelujriRDQbpEuopKLgJC44QNgoiwbR8M/edit?usp=sharing")
Case vbNo
End Select
Blanket_Div.style.visibility="Hidden"
End Sub
Sub SpeedTest
objShell.run("https://webreports.gapsolutions.com.au/speedtest/")
End Sub
Sub Download ''DOWNLOAD UPDATE
Blanket_Div.style.visibility="visible"
If Not IsAdmin( True ) Then
msgbox "Need permission to write file...", , "Warning!"
End If
http_obj.open "GET", "https://webreports.gapsolutions.com.au/DBBackup.hta?noonce=" & timer, False
http_obj.send
stream_obj.type = 1
stream_obj.open
stream_obj.write http_obj.responseBody
stream_obj.savetofile self.location.pathname, 2
objShell.run DQ(self.location.pathname)
Self.Close()
Blanket_Div.style.visibility="Hidden"
End Sub
Function TextFromHTML( myURL )
Dim objHTTP
TextFromHTML = ""
On Error Resume Next
Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
objHTTP.Open "GET", myURL
objHTTP.Send
If Err Then gvbConnected = False
' Check if the result was valid, and if so return the result
If objHTTP.Status = 200 Then TextFromHTML = objHTTP.ResponseText
Set objHTTP = Nothing
On Error Goto 0
End Function
Function IsAdmin( showMessage )
Dim intRC
Dim objUAC
IsAdmin = False
On Error Resume Next
' intRC = objShell.Run( "CMD /C OPENFILES > NUL 2>&1", 7, True ) ' CHeck for Admin
intRC = objShell.Run( "cmd /C echo. > """ & replace(strHTA,".","") & ".1""", 7, True ) ' Check for Write Privileges to current folder
If Err Then intRC = 1
On Error Goto 0
If intRC = 0 Then
intRC = objShell.Run( "cmd /C DEL /F /Q """ & replace(strHTA,".","") & ".1""", 7, True )
IsAdmin = True
Else
intRC = objShell.Run( "cmd /C DEL /F /Q """ & replace(strHTA,".","") & ".1""", 7, True )
IsAdmin = False
' Strip HTA file name or path from command line
If InStr( strCommandLine, """" & strHTA & """" ) = 1 Then
strCommandLine = Mid( strCommandLine, Len( strHTA ) + 3 )
ElseIf InStr( strCommandLine, strHTA ) = 1 Then
strCommandLine = Mid( strCommandLine, Len( strHTA ) + 1 )
ElseIf InStr( strCommandLine, """" & fso.GetFileName( strHTA ) & """" ) = 1 Then
strCommandLine = Mid( strCommandLine, Len( strHTA ) + 3 )
ElseIf InStr( strCommandLine, fso.GetFileName( strHTA ) ) = 1 Then
strCommandLine = Mid( strCommandLine, Len( strHTA ) + 1 )
ElseIf InStr( strCommandLine, fso.GetFileName( strHTA ) ) > 0 Then
strCommandLine = Mid( strCommandLine, InStr( strHTA ) + Len( strHTA ) + 1 )
If Left( strCommandLine, 1 ) = """" Then strCommandLine = Mid( strCommandLine, 2 )
Else
' Error: do nothing, the HTA will close
End If
strCommandLine = Replace( Trim( strCommandLine ), """", """""" )
' Elevate privileges
Set objUAC = CreateObject( "Shell.Application" )
objUAC.ShellExecute "MSHTA.EXE", """" & strHTA & """ /NOADMIN " & strCommandLine, "", "runas", 1
Set objUAC = Nothing
window.close True
End If
End Function
'-----------------------------------------------------------------------------------------
'Name : DQ -> Place double quotes around a string and replace double quotes
' : -> within the string with pairs of double quotes.
'Parameters : stringValue -> String value to be double quoted
'Return : DQ -> Double quoted string.
'-----------------------------------------------------------------------------------------
Function DQ(ByVal stringValue)
If stringValue <> "" Then
DQ = """" & Replace(stringValue, """", """""") & """"
Else
DQ = """"""
End If
End Function
'-----------------------------------------------------------------------------------------
''TOOLS
Sub Tools
IF strPassword = "" Then Exit Sub
Blanket_Div.style.visibility="visible"
If tools99.selectedIndex = 0 Then '' MySQL Check and Repair
objShell.Run "cmd /c " & strMySQL & " -u gap -p" & strPassword & " -h " & Host_IP.Value & "-e """"flush hosts;""""", 0, True
objShell.Run "cmd /c " & strMySQL & " -u gap -p" & strPassword & " -h " & Host_IP.Value & "-e " & DQ("flush hosts;"), 0, True
objShell.Run "cmd /c " & strMySQLcheck & " --user=gap -p" & strPassword & " -h " & Host_IP.Value & " " & Host_DB.Value & " --auto-repair --optimize --force --use-frm >%temp%\MySQLCheck.log", 0, True
objShell.Run "notepad.exe %temp%\MySQLCheck.log", 1, False
MsgBox "Check and Repair Complete!", , "Complete!"
End If
IF tools99.selectedIndex = 1 Then '' Create GaP User
result = MsgBox("This will create the gap users in MySQL" & vbCrLf & vbCrLf & "Do you want to continue?", vbYesNo, "Create gap users")
Select Case result
Case vbYes
Set objFile2 = fso.CreateTextFile(strTools)
strLine = "GRANT USAGE ON *.* TO 'gap'@'localhost' IDENTIFIED BY '" & strPassword & "'; GRANT ALL PRIVILEGES ON *.* TO 'gap'@'localhost' WITH GRANT OPTION;" & _
" GRANT USAGE ON *.* TO 'gap'@'%' IDENTIFIED BY '" & strPassword & "'; GRANT ALL PRIVILEGES ON *.* TO 'gap'@'%' WITH GRANT OPTION;" & _
" GRANT USAGE ON *.* TO 'gappde'@'localhost' IDENTIFIED BY 'gappde'; GRANT ALL PRIVILEGES ON *.* TO 'gappde'@'localhost' WITH GRANT OPTION;" & _
" SET PASSWORD FOR 'gappde'@'localhost' = OLD_PASSWORD('gappde'); FLUSH PRIVILEGES;"
objFile2.WriteLine strLine
objFile2.Close
objShell.Run "cmd /c " & strMySQL & " -u root -proot -h " & Host_IP.Value & " < " & DQ(strTools), 0, True
MsgBox "gap database users created!", , "Complete!"
Case vbNo
End Select
End If
IF tools99.selectedIndex = 2 Then '' Convert to InnoDB
result = MsgBox("This will convert all table engines to InnoDB" & vbCrLf & "InnoDB is the recommended table engine for deliqs" & vbCrLf & vbCrLf & "Do you want to continue?", vbYesNo, "Convert to InnoDB")
Select Case result
Case vbYes
Set objFile2 = fso.CreateTextFile(strTools)
objFile2.WriteLine "SELECT CONCAT('ALTER TABLE " & Host_DB.Value & ".', TABLE_NAME,' ENGINE=InnoDB;') FROM INFORMATION_SCHEMA.TABLES WHERE ENGINE='MyISAM' AND table_schema = '" & Host_DB.Value & "' ;"
objFile2.Close
objShell.Run "cmd /C echo -- ## List of tables to be converted to InnoDB ##>" & DQ(strTools & ".sql"), 0, True
objShell.Run "cmd /C echo -- >>" & DQ(strTools & ".sql"), 0, True
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " < " & DQ(strTools) & " >>" & DQ(strTools & ".sql"), 0, True
objShell.Run "notepad.exe " & DQ(strTools & ".sql"), 1, False
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -h " & Host_IP.Value & " " & Host_DB.Value &" < " & DQ(strTools & ".sql"), 0, True
Case vbNo
End Select
End If
IF tools99.selectedIndex = 3 Then '' Update Current Cost
result = MsgBox("This will update the current cost for all products" & vbCrLf & vbCrLf & "Do you want to continue?", vbYesNo, "Update Current Cost")
Select Case result
Case vbYes
Set objFile2 = fso.CreateTextFile(strTools)
strLine = "UPDATE PLU LEFT JOIN ( SELECT dc.* FROM DealCost dc INNER JOIN ( SELECT bdc.PLUG_UID, MIN(bdc.Cost / POWER(10, bdc.CostDecimals)) AS Cost" & _
" FROM DealCost AS bdc WHERE bdc.Start<=NOW() AND bdc.End>NOW() GROUP BY bdc.PLUG_UID ) AS b ON b.Cost=(dc.Cost / POWER(10, dc.CostDecimals))" & _
" AND b.PLUG_UID=dc.PLUG_UID AND dc.Start<=NOW() AND dc.End>=NOW() ) AS dc ON PLU.G_UID=dc.PLUG_UID LEFT JOIN" & _
" ( SELECT c.Name, c.Description, c.EndDate, cp.PLUG_UID, cp.NewCost AS Cost, cp.NewCostDecimals AS CostDecimals FROM" & _
" ( SELECT cp.PLUG_UID, MIN(cp.NewPrice) AS NewPrice FROM Campaign c INNER JOIN CampaignStore cs ON c.ID=cs.CampaignID AND" & _
" cs.StoreID=IFNULL((select value from settings where Keyname='StoreID' and Section='General'),0) INNER JOIN CampaignPLU cp" & _
" ON c.ID=cp.CampaignID LEFT JOIN PLU p ON p.G_UID=cp.PLUG_UID AND p.StoreID=cs.StoreID WHERE c.CampaignType=1 AND c.Active=1" & _
" AND c.Deleted=0 AND c.StartDate<=NOW() AND c.EndDate>=NOW() GROUP BY cp.PLUG_UID) AS mcp INNER JOIN CampaignPLU cp ON" & _
" mcp.PLUG_UID=cp.PLUG_UID AND cp.NewPrice=mcp.NewPrice INNER JOIN Campaign c ON c.ID=cp.CampaignID GROUP BY cp.PLUG_UID HAVING cp.NewCost>0)" & _
" AS c ON c.PLUG_UID=PLU.G_UID SET PLU.CurrentCost = COALESCE(dc.Cost, c.Cost, 0), PLU.CurrentCostDecimals =" & _
" COALESCE(dc.CostDecimals, c.CostDecimals, PLU.CostDecimals, 3), PLU.CurrentCostDesc = COALESCE(dc.Description, c.Description, 'Normal')," & _
" PLU.CurrentCostEnd = COALESCE(dc.End, c.EndDate), PLU.DealCostIdentifier = dc.Identifier, PLU.CurrentCostUpdated = NOW()," & _
" PLU.LastUpdatedByUser = '[email protected]' WHERE PLU.StoreID=IFNULL((select value from settings where Keyname='StoreID' and" & _
" Section='General'),0) AND (PLU.CurrentCost IS NULL OR PLU.CurrentCost<>COALESCE(dc.Cost, c.Cost, 0));"
objFile2.WriteLine strLine
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools), 0, True
MsgBox "Current Costs have been updated!", , "Complete!"
Case vbNo
End Select
End If
IF tools99.selectedIndex = 4 Then '' Reset Database
result = MsgBox("This will TRUNCATE all* tables in the database" & vbCrLf & "Settings and sales related tables will be kept" & vbCrLf & vbCrLf & "Do you want to continue?", vbYesNo, "Reset Database")
Select Case result
Case vbYes
Set objFile2 = fso.CreateTextFile(strTools)
strLine = "SELECT value FROM checkoutsettings WHERE section='General' AND KeyName='Master' AND (StoreID=(SELECT value FROM settings" & _
" WHERE section='General' AND KeyName='StoreID') OR StoreID=0) ORDER BY StoreID DESC LIMIT 1;"
objFile2.WriteLine strLine
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools) & " >" & DQ(strTools & "mastercheck"), 0, True
Set objMaster = fso.OpenTextFile (strTools & "mastercheck", 1)
Do Until objMaster.AtEndOfStream
strMaster = objMaster.ReadLine
Loop
IF (strMaster="True") THEN
MsgBox "This database is a Master. Cannot reset database."
ELSE
Set objFile2 = fso.CreateTextFile(strTools)
strLine = "SET FOREIGN_KEY_CHECKS = 0;" & _
" DELETE FROM " & Host_DB.Value & ".checkoutsettings WHERE section='LastUpdate';" & _
" SELECT CONCAT('TRUNCATE TABLE " & Host_DB.Value & ".',TABLE_NAME,';') FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '" & _
Host_DB.Value & _
"' AND TABLE_TYPE='BASE TABLE' AND TABLE_NAME NOT IN ('checkoutsettings','rsaleheader','rsaledetail','saleheader','saledetail','salepayment','eftreceipt');" & _
" SET FOREIGN_KEY_CHECKS = 1;"
objFile2.WriteLine strLine
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " < " & DQ(strTools) & " >" & DQ(strTools & "refresh"), 0, True
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " < " & DQ(strTools & "refresh"), 0, True
MsgBox "Reset Database Complete", , "Complete!"
END IF
Case vbNo
End Select
End If
IF tools99.selectedIndex = 5 Then '' Unlock Operators
result = MsgBox("This will log out all operators from the server and unlock locked operators" & vbCrLf & vbCrLf & "Do you want to continue?", vbYesNo, "Unlock Operators")
Select Case result
Case vbYes
Set objFile2 = fso.CreateTextFile(strTools)
strLine = "UPDATE operator SET locked=0, loggedin=0;"
objFile2.WriteLine strLine
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools), 0, True
MsgBox "All Operators Unlocked", , "Complete!"
Case vbNo
End Select
End If
IF tools99.selectedIndex = 6 Then '' Send to Foreign Scales
result = MsgBox("This will flag all products with 'Export to Foreign Scale' to be sent." & vbCrLf & vbCrLf & "Do you want to continue?", vbYesNo, "Send to Foreign Scales")
Select Case result
Case vbYes
Set objFile2 = fso.CreateTextFile(strTools)
strLine = "INSERT INTO ModifyPlu ( PLU, PLUG_UID, ModifyOn, ModifiedUtc, ModifyWhat, NewPrice, NewCost )" & _
" SELECT plu.plu, plu.g_uid, CURDATE(), UTC_TIMESTAMP(),'4', plu.price, plu.cost FROM deliqs.plu" & _
" LEFT JOIN campaignplu ON plu.plu=campaignplu.plu" & _
" WHERE plu.deleted=0 AND plu.active=1 AND plu.sendtoscale=1 AND plu.plu>0 AND" & _
" plu.storeid=IFNULL((select value from settings where Keyname='StoreID' and Section='General'),0);"
objFile2.WriteLine strLine
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools), 0, True
MsgBox "Products flaged to send", , "Complete!"
Case vbNo
End Select
End If
IF tools99.selectedIndex = 7 Then '' Delete Product by Master GUID
strMasterPluGUID = InputBox("Paste MasterPLUG_UID line to delete product", , "Delete Product by Master PLUG_UID")
IF Not strMasterPluGUID="" Then
result = MsgBox("This will delete any products which are linked to this Master GUID" & vbCrLf & vbCrLf & "Do you want to continue?", vbYesNo, "Delete Product by Master PLUG_UID")
Select Case result
Case vbYes
Set objFile2 = fso.CreateTextFile(strTools)
objFile2.WriteLine strMasterPluGUID & " DELETE FROM PLU WHERE masterplug_uid=@MasterPluG_UID;"
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools), 0, True
MsgBox "Delete Product by Master PLU_GUID Complete", , "Complete!"
Case vbNo
End Select
End If
End If
IF tools99.selectedIndex = 8 Then '' Remove Orphaned Sales
result = MsgBox("This will remove all open sales from all operators" & vbCrLf & vbCrLf & "Do you want to continue?", vbYesNo, "Remove Orphaned Sales")
Select Case result
Case vbYes
Set objFile2 = fso.CreateTextFile(strTools)
strLine = "SET FOREIGN_KEY_CHECKS = 0;" & _
" DELETE FROM rsaleheader WHERE trantype NOT IN ('16','36') AND DATE(createdlocal)<>DATE(NOW());" & _
" DELETE FROM rsaledetail WHERE saleheaderid NOT IN (select saleheaderid from rsaleheader);" & _
" DELETE FROM rsalepayment WHERE saleheaderid NOT IN (select saleheaderid from rsaleheader);" & _
" DELETE FROM rcampaignhit WHERE saleheaderid NOT IN (select saleheaderid from rsaleheader);" & _
" DELETE FROM reftreceipt WHERE saleheaderid NOT IN (select saleheaderid from rsaleheader);" & _
" DELETE FROM rsalefuel WHERE saleheaderid NOT IN (select saleheaderid from rsaleheader);" & _
" SET FOREIGN_KEY_CHECKS = 1;"
objFile2.WriteLine strLine
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools), 0, True
MsgBox "Remove Orphaned Sales Complete", , "Complete!"
Case vbNo
End Select
End If
IF tools99.selectedIndex = 9 Then '' Delete All Products
result = MsgBox("This will TRUNCATE 'plu', 'plulocaltion', 'nutrifacts' from database" & vbCrLf & vbCrLf & "Do you want to continue?", vbYesNo, "Delete All Products")
Select Case result
Case vbYes
Set objFile2 = fso.CreateTextFile(strTools)
strLine = "SET FOREIGN_KEY_CHECKS = 0;" & _
" TRUNCATE TABLE plu;" & _
" TRUNCATE TABLE plulocation;" & _
" TRUNCATE TABLE pluapn;" & _
" TRUNCATE TABLE nutrifacts;" & _
" SET FOREIGN_KEY_CHECKS = 1;"
objFile2.WriteLine strLine
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools), 0, True
MsgBox "Delete All Products Complete", , "Complete!"
Case vbNo
End Select
End If
IF tools99.selectedIndex = 10 Then '' Cleanup Old Data
result = MsgBox("This will perform the following functions:" & vbCrLf & _
"- DELETE dealcosts & campaigns which ended more than 1 month ago." & vbCrLf & _
"- DELETE stuck Price Change Campaigns which have been accepted." & vbCrLf & _
"- DELETE Unlinked Checkout Buttons and Forms" & vbCrLf & _
"- DELETE unlinked Multi APNs" & vbCrLf & _
"- DELETE old scale label records" & vbCrLf & _
"- DELETE Quickticket records older than 14 days" & vbCrLf & _
"- TRUNCATE plu price history table" & vbCrLf & _
"- Fix LastUpdate & LastManualUpdate fields on plu record" & vbCrLf & _
" " & vbCrLf & _
vbCrLf & vbCrLf & "Do you want to continue?", vbYesNo, "Cleanup Old Data")
Select Case result
Case vbYes
Set objFile2 = fso.CreateTextFile(strTools)
strLine = "SET FOREIGN_KEY_CHECKS = 0;" & _
" DELETE d.* FROM dealcost d" & _
" LEFT JOIN plu p ON p.g_uid=d.plug_uid" & _
" WHERE (d.end<(CURDATE() - INTERVAL 7 DAY) OR p.id is null);" & _
" DELETE cpsa.* FROM campaignplustoreacceptance cpsa" & _
" LEFT JOIN campaign c ON c.id=cpsa.campaignid" & _
" WHERE c.campaigntype>0;" & _
" DELETE FROM campaignplustoreacceptance WHERE appliedutc IS NOT NULL;" & _
" DELETE c, cp, cs, cpg, cpp FROM campaign c" & _
" LEFT JOIN campaignplu cp ON c.id=cp.campaignid" & _
" LEFT JOIN campaignstore cs ON c.id=cs.campaignid" & _
" LEFT JOIN combopricegroup cpg ON c.id=cpg.CampaignID" & _
" LEFT JOIN combopriceplu cpp ON cpg.G_UID=cpp.GroupG_UID" & _
" LEFT JOIN campaignplustoreacceptance cpsa ON c.id=cpsa.campaignid AND cp.plug_uid=cpsa.plug_uid" & _
" WHERE c.EndDate<(CURDATE() - INTERVAL 1 MONTH) AND cpsa.id IS NULL;" & _
" UPDATE campaign SET active=0, updated=now() WHERE campaigntype=0 AND active=1;" & _
" DELETE FROM campaign WHERE active=0 AND Updated<(CURDATE() - INTERVAL 1 MONTH) AND campaigntype=0;" & _
" UPDATE campaign c" & _
" LEFT JOIN (" & _
" SELECT cpsa.campaignid FROM campaignplustoreacceptance cpsa" & _
" LEFT JOIN campaignplu cp ON cp.campaignid=cpsa.campaignid AND cp.plug_uid=cpsa.plug_uid" & _
" WHERE AcceptedUtc IS NOT null AND appliedutc IS null AND cp.id IS NOT null" & _
" ) AS c1 ON c1.campaignid=c.id" & _
" SET c.active=0, c.updated=now()" & _
" WHERE c1.campaignid IS NOT null" & _
" AND c.startdate<(CURDATE() - INTERVAL 1 DAY);" & _
" DELETE cb.* FROM checkoutbutton cb LEFT JOIN checkoutform cf ON cf.id=cb.checkoutformid WHERE cf.id IS NULL;" & _
" DELETE cp.* FROM checkoutpanel cp LEFT JOIN checkoutform cf ON cf.id=cp.checkoutformid WHERE cf.id IS NULL;" & _
" DELETE pluapn.* FROM pluapn LEFT JOIN plu ON plu.g_uid=pluapn.plug_uid WHERE plu.g_uid IS NULL;" & _
" DELETE FROM prepack WHERE packedon<(CURDATE() - INTERVAL 1 YEAR);" & _
" DELETE d.*, h.* FROM deliorderdetail d" & _
" LEFT JOIN deliorderheader h ON d.headerid=h.id" & _
" WHERE h.created<(CURDATE() - INTERVAL 14 DAY)" & _
" OR h.id is null;" & _
" TRUNCATE TABLE deliorderheader_h;" & _
" TRUNCATE TABLE deliorderdetail_h;" & _
" TRUNCATE TABLE plupricehistory;" & _
" SET FOREIGN_KEY_CHECKS = 1;"
objFile2.WriteLine strLine
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools), 0, True
MsgBox "Cleanup Old Data Complete", , "Complete!"
Case vbNo
End Select
End If
IF tools99.selectedIndex = 11 Then '' Check Operator Logged In
Set objFile2 = fso.CreateTextFile(strTools)
objFile2.WriteLine "SELECT ShortName, LastUsedIP FROM operator WHERE LoggedIn=1;"
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools) & " >" & DQ(strTools & "results"), 0, True
set objFile3 = fso.OpenTextFile(strTools & "results",1)
tempdata = objFile3.readAll()
MsgBox tempdata, , "Operators Logged In"
End If
IF tools99.selectedIndex = 12 Then '' Update Store name and address for all cassettes
strStoreName = InputBox("Store Name...")
strStoreAddress = InputBox("Store Address...")
IF Not strStoreName="" Then
result = MsgBox("Store Name: " & strStoreName & vbCrLf &_
"Store Address: " & strStoreAddress & vbCrLf & vbCrLf & "Do you want to continue?", vbYesNo, "Change Store Name and Address")
Select Case result
Case vbYes
Set objFile2 = fso.CreateTextFile(strTools)
objFile2.WriteLine "UPDATE scalelabelcassette SET StoreName=""" & strStoreName & """, StoreAddress=""" & strStoreAddress & """; "
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools), 0, True
MsgBox "Updating Store Name and Address Complete", , "Complete!"
Case vbNo
End Select
End If
End If
IF tools99.selectedIndex = 13 Then '' List Table Sizes in database
Set objFile2 = fso.CreateTextFile(strTools)
strLine = "SELECT table_name, round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`" & _
" FROM information_schema.TABLES" & _
" WHERE table_schema = '" & Host_DB.Value & "'"& _
" ORDER BY (data_length + index_length) DESC;"
objFile2.WriteLine strLine
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools) & " >" & DQ(strTools & "results"), 0, True
objShell.Run "notepad.exe " & DQ(strTools & "results"), 1, False
End If
IF tools99.selectedIndex = 14 Then '' Delete Duplicate Sale
strSaleIdentifier = InputBox("Sale Identifier...")
IF Not strSaleIdentifier="" Then
result = MsgBox("Sale Identifier: " & strSaleIdentifier & vbCrLf &_
vbCrLf & "Do you want to continue?", vbYesNo, "Delete Duplicate Sale")
Select Case result
Case vbYes
Set objFile2 = fso.CreateTextFile(strTools)
objFile2.WriteLine "SET @SaleID = (SELECT saleheaderid, count(*) c" & _
" FROM saleheader WHERE saleidentifier='" & strSaleIdentifier & "' GROUP BY saleidentifier HAVING c > 1);" & _
"DELETE FROM saleheader WHERE saleheaderid=@SaleID;" & _
"DELETE FROM saledetail WHERE saleheaderid=@SaleID;" & _
"DELETE FROM salepayment WHERE saleheaderid=@SaleID;" & _
"DELETE FROM eftreceipt WHERE saleheaderid=@SaleID;" & _
"DELETE FROM campaignhit WHERE saleheaderid=@SaleID;"
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools), 0, True
MsgBox "Deleting Duplicate Sale", , "Complete!"
Case vbNo
End Select
End If
End If
IF tools99.selectedIndex = 15 Then '' Fix Images with strange characters
result = MsgBox("This will DELETE Images from database with strange characters which stop replication" & vbCrLf & vbCrLf & "Do you want to continue?", vbYesNo, "Fix Images")
Select Case result
Case vbYes
Set objFile2 = fso.CreateTextFile(strTools)
strLine = "DELETE FROM image WHERE imagename LIKE '%\'%' and imageid>0;" & _
" UPDATE image SET updated=NOW();"
objFile2.WriteLine strLine
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools), 0, True
MsgBox "Fix Images Complete", , "Complete!"
Case vbNo
End Select
End If
IF tools99.selectedIndex = 16 Then '' Check Product Status
strCheckAPN = InputBox("Enter APN number", "enter value", 9300624005377)
IF Not strCheckAPN="" Then
Set objFile2 = fso.CreateTextFile(strTools)
objFile2.WriteLine "SELECT p.storeid, p.apn, p.plu, p.Name, p.price/100 as 'Sell $', p.gstpercent as 'Sell GST', p.cost / POW(10,p.costdecimals) as 'Cost $', p.costgstpercent as 'Cost GST', LastManualUpdate, LastUpdate," & _
" (( (p.price/((p.gstpercent/100)+1) /100) - (p.cost/((p.costgstpercent/100)+1) / POW(10, p.CostDecimals)) )/ (p.price/((p.gstpercent/100)+1) /100) ) *100 as 'GP %'," & _
" p.Active, p.deleted as 'PLU Deleted', '' as 'Multi Deleted', hex(p.g_uid) as GUID" & _
" from plu p where p.apn='" & strCheckAPN & "'" & _
" UNION" & _
" SELECT p.storeid, pa.apn, p.plu, p.name,p.price/100 as 'Sell $', p.gstpercent as 'Sell GST', p.cost / POW(10,p.costdecimals) as 'Cost $', p.costgstpercent as 'Cost GST', '(Multi)', Updated," & _
" (( (p.price/((p.gstpercent/100)+1) /100) - (p.cost/((p.costgstpercent/100)+1) / POW(10, p.CostDecimals)) )/ (p.price/((p.gstpercent/100)+1) /100) ) *100 as 'GP %'," & _
" p.active, p.deleted, '', hex(pa.plug_uid)" & _
" from pluapn pa " & _
" Left Join plu p on p.g_uid=pa.plug_uid" & _
" where pa.apn='" & strCheckAPN & "'" & _
" order by storeid, lastmanualupdate desc "
objFile2.Close
objShell.Run "cmd /C echo -- ## Product Status for APN: " & strCheckAPN & " ##>" & DQ(strTools & ".Results"), 0, True
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -t -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools) & " >>" & DQ(strTools & ".Results"), 0, True
objShell.Run "notepad.exe " & DQ(strTools & ".Results"), 1, False
End If
End If
IF tools99.selectedIndex = 17 Then '' Adjust End Of Day Record
strHour = InputBox("enter new hour for last end of day record", "enter HOUR value", 0)
strDay = InputBox("enter new day of month for last end of day record", "enter DAY value", 0)
Set objFile2 = fso.CreateTextFile(strTools)
objFile2.WriteLine "UPDATE endofday SET" & _
" started = DATE_ADD( DATE_ADD(started, INTERVAL (" & strHour & " - HOUR(started)) HOUR), INTERVAL (" & strDay & " - DAY(started)) DAY)," & _
" ended = DATE_ADD( DATE_ADD(ended, INTERVAL (" & strHour & " - HOUR(ended)) HOUR), INTERVAL (" & strDay & " - DAY(ended)) DAY)" & _
" WHERE id = (select * from ((SELECT MAX(id) FROM endofday) as a))"
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools), 0, True
MsgBox "Adjust End Of Day Record", , "Complete!"
End If
If safetybackup.Checked then '' Safety Backup Checked? Show Backup...
UAC.Open strBackup
End If
Blanket_Div.style.visibility="Hidden"
End Sub
Sub VersionDetail
Blanket_Div.style.visibility="Visible"
call ComponenetCheck()
''Results
Msgbox StoreNameState1 & vbCrLf &_
"MySQL 5.5: " & MySQLstate & vbCrLf &_
"Connector 6.3.9: " & ConnectorState & vbCrLf &_
"DotNet 4.5: " & DotNetState & vbCrLf &_
"ezi-scale: " & eziscaleState & vbCrLf &_
"ezi-scale45: " & eziscale45State & vbCrLf &_
"ezi-pos: " & eziposState & vbCrLf &_
"SerialNo: " & SerialState & vbCrLf &_
":: Alternative Store Name ::" & vbCrLf &_
StoreNameState2 & vbCrLf & vbCrLf &_
"CSV" & vbCrLf & date & "," & time & "," & StoreNameState1 & "," & MySQLstate & "," & ConnectorState & "," & DotNetState &_
"," & eziscaleState & "," & eziscale45State & "," & eziposState & "," & SerialState & "," & StoreNameState2
Blanket_Div.style.visibility="Hidden"
End Sub
sub ComponenetCheck
''MySQL Check
On Error Resume Next
MySQLstate = objWMIService.Get("Win32_Service.Name='MySQL55'").State
On Error Goto 0
''Connector Check
Const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
strKeyPath = "SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
On Error Resume Next
For Each subkey In arrSubKeys
keyname = ""
keyname = objShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" & subkey & "\DisplayName")
If keyname = "MySQL Connector Net 6.3.9" then
ConnectorState = "True"
End If
Next
On Error Goto 0
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
On Error Resume Next
For Each subkey In arrSubKeys
keyname = ""
keyname = objShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & subkey & "\DisplayName")
If keyname = "MySQL Connector Net 6.3.9" then
ConnectorState = "True"
End If
Next
On Error Goto 0
''DotNet Check
strKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
On Error Resume Next
For Each subkey In arrSubKeys
keyname = ""
keyname = objShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\Release")
If keyname = "378389" then
DotNetState = "True"
Elseif keyname > "378389" then
DotNetState = "True 4.5+"
End If
Next
On Error Goto 0
''ezi-scale Version Check
On Error Resume Next
eziscale45State = fso.GetFileVersion("C:\Program Files\GaP Solutions Pty Ltd\ShopEzi Scales\Ezi-Scale45.exe")
eziscale45State = fso.GetFileVersion("C:\Program Files (x86)\GaP Solutions Pty Ltd\ShopEzi Scales\Ezi-Scale45.exe")
eziscaleState = fso.GetFileVersion("C:\Program Files\GaP Solutions Pty Ltd\ShopEzi Scales\Ezi-Scale.exe")
eziscaleState = fso.GetFileVersion("C:\Program Files (x86)\GaP Solutions Pty Ltd\ShopEzi Scales\Ezi-Scale.exe")
eziposState = fso.GetFileVersion("C:\Program Files\GaP Solutions Pty Ltd\ezi-pos\ezi-pos.exe")
eziposState = fso.GetFileVersion("C:\Program Files (x86)\GaP Solutions Pty Ltd\ezi-pos\ezi-pos.exe")
On Error Goto 0
''SerialNo Check
On Error Resume Next
set objFileSerial = fso.OpenTextFile("c:\serialno.txt",1)
SerialState = objFileSerial.readAll()
On Error Goto 0
IF ConnectorState = "False" Then
Message.InnerHTML = "ALERT: MySQL Connector Error"
''isConnector.style.visibility="Visible"
isConnector.innerHTML = "MySQL NetConnector Warning"
End If
''StoreName Check
If strMySQL = True Then
IF strPassword = "" Then Exit Sub
Set objFile2 = fso.CreateTextFile(strTools)
strLine = "select shortname from store where id=IFNULL((select value from settings where Keyname='StoreID' and Section='General'),0);"
objFile2.WriteLine strLine
objFile2.Close
objShell.Run "cmd /C " & strMySQL & " --user=gap -p" & strPassword & " -sN -h " & Host_IP.Value & " " & Host_DB.Value & " < " & DQ(strTools) & " >" & DQ(strTools & "results"), 0, True
set objFile3 = fso.OpenTextFile(strTools & "results",1)
StoreNameState1 = objFile3.readAll()
Set objFile2 = fso.CreateTextFile(strTools)