<html>
<head><title>LocalWeb Update Utility</title>
<HTA:APPLICATION ID="oHTA";
APPLICATIONNAME="LocalWeb Update Utility";
ICON="Backup.ico";
BORDER="thin";
BORDERSTYLE="normal";
SINGLEINSTANCE="no";
MAXIMIZEBUTTON="no";
VERSION="1.0";
CONTEXTMENU="no";
>
</head><body bgcolor="#E8E8E8" >
<font size=2 face="Century Gothic, Tahoma, Arial" color="black">
<script language="VBScript" type="text/vbscript">
Sub Sync
If browseFolder.value = "" Then
MsgBox "Please enter a valid path to save the files.", 1, "Error"
Else
Const SOURCE_FOLDER = "SERVER.value"
Const DESTINATION_FOLDER = "browseFolder.value"
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
ReplicateFolders oFSO, SOURCE_FOLDER, DESTINATION_FOLDER
End If
End Sub
'******************
' Sub ReplicateFolders
'
' This procedure replicates between the source and the destination
' directories at the folder level. A recursive search is done
' between the 2 directories and folders compared. If a particular
' folder on the source does not exist on the destination at any level then the
' source folder and all folders and files associated with it are
' copied to the destination. If a particular folder on the destination
' does not exist on the source at any level then the destination folder
' is removed from the destination directory.
'
'******************
Sub ReplicateFolders (oFSO, strSourcefolderpath, strDestinationfolderpath)
Dim aFolderArraySource
Dim aFolderArrayDestination
Dim FolderListSource
Dim FolderListDestination
Dim oFolderSource
Dim oFolderDestination
Dim bSourceExists
Dim bDestinationExists
On Error Resume Next
Set aFolderArraySource = oFSO.GetFolder(strSourcefolderpath)
Set aFolderArrayDestination = oFSO.GetFolder(strDestinationfolderpath)
Set FolderListSource = aFolderArraySource.SubFolders
Set FolderListDestination = aFolderArrayDestination.SubFolders
' Compare to see if destination folder does not exist. If it does not
' then copy from the source.
For Each oFolderSource in FolderListSource
bDestinationExists = 0
For each oFolderDestination in FolderListDestination
If oFolderSource.Name = oFolderDestination.Name then
bDestinationExists = 1
Exit For
End If
Next
If bDestinationExists = 0 then
oFolderSource.Copy strDestinationfolderpath & "\"
Else
'This is the recursive bit. Traverse the path one level down
ReplicateFolders oFSO, strSourcefolderpath & "\" & oFolderSource.Name, strDestinationfolderpath & "\" & oFolderDestination.Name
End if
Next
' After taking care of the folders, deal with the files at each folder level.
ReplicateFiles oFSO, strSourcefolderpath, strDestinationfolderpath
' Compare to see if a folder on the destination drive does not exist
' in the source directory. If this is the case then delete the destination
' folder.
For Each oFolderDestination in FolderListDestination
bSourceExists = 0
For each oFolderSource in FolderListSource
If oFolderDestination.Name = oFolderSource.Name then
bSourceExists = 1
Exit For
End If
Next
If bSourceExists = 0 then
oFSO.DeleteFolder strDestinationfolderpath & "\" & oFolderDestination.Name, true
End if
Next
End Sub
'******************
' Sub ReplicateFiles
'
' This procedure replicates between the source and the destination
' directories at the file level.
' If a particular file on the source does not exist on the destination
' at any level then the source file is copied to the destination.
' If a particular file on the destination directory
' does not exist on the source at any level then the destination file
' is removed from the destination directory.
'
'******************
Sub ReplicateFiles (oFSO, strSourcefolderpath, strDestinationfolderpath)
Dim aFileArraySource
Dim aFileArrayDestination
Dim FileListSource
Dim FileListDestination
Dim oFileSource
Dim oFileDestination
Dim bSourceExists
Dim bDestinationExists
Dim intFCount
Dim i
Dim intPercentComplete
On Error Resume Next
Set aFileArraySource = oFSO.GetFolder(strSourcefolderpath)
Set aFileArrayDestination = oFSO.GetFolder(strDestinationfolderpath)
Set FileListSource = aFileArraySource.Files
Set FileListDestination = aFileArrayDestination.Files
' Comparing the array entry properties (name and date last modified) of each array.
' If the source file array entry matches the destination file array entry then
' the source file is not copied to the destination directory.
' Otherwise, the source file is copied to the destination directory and
' any existing copy of the same file in the destination directory
' is overwritten.
i = 0
intFCount = 0
intPercentComplete = 0
For each oFileSource in FileListSource
bDestinationExists = 0
For each oFileDestination In FileListDestination
If oFileSource.Name = oFileDestination.Name Then
If oFileSource.DateLastModified = oFileDestination.DateLastModified AND o.FileSource.Size = oFileDestination.Size then
bDestinationExists = 1
Exit For
End If
End If
Next
If bDestinationExists = 0 Then
intFCount = intFCount + 1
oFileSource.Copy strDestinationfolderpath & "\" & oFileSource.Name
i = i + 1
intPercentComplete = (i * 100) / intFCount
Wscript.Echo intPercentComplete & "% copy of total " & intFCount & " files complete"
End If
Next
' Comparing the array entry properties (name and date last modified) of each array.
' If the destination file array entry matches the source file array entry then
' the destination file is not deleted from the destination directory.
' Otherwise, the destination file is deleted from the destination directory.
For each oFileDestination In FileListDestination
bSourceExists = 0
For each oFileSource In FileListSource
If oFileDestination.Name = oFileSource.Name then
If oFileDestination.DateLastModified = oFileSource.DateLastModified Then
bSourceExists = 1
Exit For
End If
End If
Next
If bSourceExists = 0 Then
oFSO.DeleteFile strDestinationfolderpath & "\" & oFileDestination.Name,true
End If
Next
End Sub
Sub ChooseSaveFolder
strStartDir = "c:\"
browseFolder.value = PickFolder(strStartDir)
End Sub
Function PickFolder(strStartDir)
Dim SA, F
Set SA = CreateObject("Shell.Application")
Set F = SA.BrowseForFolder(0, "Choose the LocalWeb Folder", 0)
If (Not F Is Nothing) Then
PickFolder = F.Items.Item.path
End If
Set F = Nothing
Set SA = Nothing
End Function
</script>
<p><b>This application will update your version of the LocalWeb.<br>
Choose the source and destination directory you desire, <br>and click the Update-button.<br><br>
<font color="red">P.S.: </font>When updating from your home, please make sure<br>
that your VPN connection is up and running.</b><hr noshode color="#000000"><br></p>
<p></p>
<table>
<tr>
<td>Source:</td>
<td><select name="SERVER">
<option selected value="Y:\test1">SERVER VILVOORDE (DEFAULT)</option>
</select></td></tr>
<tr></tr>
<tr>
<td>Destination:</td>
<td><input type="text" name="browseFolder" size="50">
<input name="browseButton" type = "button" value = "Browse ..." onClick="ChooseSaveFolder"></td></tr></table>
<p align=center><input type="submit" name="B1" value="Update" onclick="Sync"></p>
<div id=LogOut></div>
<script language="JavaScript">
<!--
if (window.resizeTo) self.resizeTo(600,400);
//-->
</script>
</body>
</html>