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
|
Sub test()
svn_path = Range("A1")
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Set FS = CreateObject("Scripting.FileSystemObject")
Set FSfolder = FS.GetFolder(svn_path)
For Each subfolder In FSfolder.SubFolders
'backup file.conf
FromPath = subfolder & "\file.conf"
ToPath = subfolder & "\file.conf.bak"
If (FS.FileExists(FromPath)) Then
FS.CopyFile Source:=FromPath, Destination:=ToPath
Set ff = FS.GetFile(subfolder & "\file.conf")
If ff.Size <> 0 Then
Set f = ff.OpenAsTextStream(ForReading, 0)
jct = f.readall
jct2 = Split(jct, vbLf)
jct_loc = ""
jct_hors = ""
f.Close
Set f = ff.OpenAsTextStream(ForWriting, 0)
For n = 0 To UBound(jct2)
m = jct2(n)
If InStr(1, m, "<Location") Then
loca = Split(m, " ")
End If
If InStr(1, LCase(m), "proxypass") Then
m = Replace(LCase(m), "proxypass ", "proxypass " & loca(1) & " ")
m = Replace(LCase(m), "proxypassreverse ", "proxypassreverse " & loca(1) & " ")
jct_hors = jct_hors & vbLf & m
Else
jct_loc = jct_loc & vbLf & m
End If
Next n
tst = Split(jct_loc, vbLf)
If UBound(tst) = 2 Then
jct_loc = ""
End If
jct_hors = Replace(jct_hors, "proxypassreverse", "ProxyPassReverse")
jct_hors = Replace(jct_hors, "proxypass", "ProxyPass")
f.Write jct_hors & vbLf & jct_loc
f.Close
End If
End If
Next subfolder
End Sub
Private Sub CommandButton1_Click()
test
End Sub |
Partager