~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hotlink_config.asp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<%
hotlink_last = "AAA"
hotlink_current = "BBB"
%>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hotlink_update.asp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<%
website_id = "[the numeric id]"
image_folder = "[image subfolder name]"
site_root = "[site folder if not at the root of the site]"
new_folder = RewriteConfig(hotlink_current)
Response.Write "Deleting Virtual Directory (" & hotlink_last & ")
"
DeleteVirtualDirectory website_id, site_root, hotlink_last
Response.Write "Creating Virtual Directory (" & new_folder & ")
"
CreateVirtualDirectory website_id, site_root, new_folder, Server.MapPath(imagefolder)
Sub DeleteVirtualDirectory(id, folder, name)
If folder = "" Then
Set root = GetRoot(id)
Else
Set root = GetSubFolder(id, folder)
End If
On Error Resume Next
root.Delete "IIsWebVirtualDir", name
On Error Goto 0
End Sub
Sub CreateVirtualDirectory(id, folder, name, path)
If folder = "" Then
Set root = GetRoot(id)
Else
Set root = GetSubFolder(id, folder)
End If
' Add a virtual directory to the site.
Set oVDir = root.Create("IIsWebVirtualDir", name)
oVDir.Path = path
oVDir.AuthFlags = 5 ' AuthNTLM + AuthAnonymous
oVDir.EnableDefaultDoc = True
oVDir.DirBrowseFlags = &H4000003E ' date, time, size, extension, longdate
oVDir.AccessFlags = 513 ' read, script
oVDir.AccessExecute = False
oVDir.AccessScript = False
oVDir.AccessWrite = False
oVDir.AccessRead = True
oVDir.EnableDirBrowsing = False
oVDir.DontLog = True
' Commit the new directory
oVDir.SetInfo
End Sub
Function GetRoot(id)
Set GetRoot = GetObject("IIS://localhost/W3svc/" & id & "/Root")
End Function
Function GetSubFolder(id, folder)
Set GetSubFolder = GetObject("IIS://LocalHost/W3svc/" & id & "/Root/" & folder)
End Function
Function RewriteConfig(current)
Randomize
' Create the random directory name
hotlink_new = Chr(Asc("A") + Rnd * 25) + _
Chr(Asc("A") + Rnd * 25) + _
Chr(Asc("A") + Rnd * 25) + _
Chr(Asc("A") + Rnd * 25) + _
Chr(Asc("A") + Rnd * 25) + _
Chr(Asc("A") + Rnd * 25) + _
Chr(Asc("A") + Rnd * 25) + _
Chr(Asc("A") + Rnd * 25) + _
Chr(Asc("A") + Rnd * 25) + _
Chr(Asc("A") + Rnd * 25) + _
Chr(Asc("A") + Rnd * 25) + _
Chr(Asc("A") + Rnd * 25) + _
Chr(Asc("A") + Rnd * 25) + _
Chr(Asc("A") + Rnd * 25)
' Write out the config file (which is just an ASP file)
Set oFS = Server.CreateObject("Scripting.FileSystemObject")
Set oT = oFS.CreateTextFile(Server.MapPath(".\hotlink_config.asp"), True)
oT.Write "<" & "% " & vbCRLF & _
" hotlink_last = """ & current & """" & vbCRLF & _
" hotlink_current = """ & hotlink_new & """" & vbCRLF & _
"%" & ">"
oT.Close
RewriteConfig = hotlink_new
Set oFS = Nothing
End Function
%>