if sætninger i koden ? hva ellers ?
Hejsa allesammenjeg har fundet nedenstående kode på nettet og jeg bruger den til at fjerne IIS script-mappings med fx understøttelse af .asp, .php og .cgi...
(denne kode er til at fjerne .php extension med fra IIS serveren og koden virker helt perfekt og den gør det den skal!)
<%
if request("mode") = opret then
Dim strExt
Dim myValue
dim strNothing
dim strBuild
dim i
dim iValue
Set myValue = GetObject("IIS://LocalHost/W3SVC/3/root")
'Returns an array multi valued list
'Puts the values in a local array variable myArray
myArray = myValue.Get("ScriptMaps")
'Loops through building a string
'based on myArray list of values
For i = 0 To UBound(myArray)
iValue = InStr(myArray(i), ",")
strExt = Left(myArray(i), iValue - 1)
Select Case strExt
Case ".php", ".phtml", ".php3", ".php4"
'Builds a bogus string of un-needed mappings
strNothing = strNothing & myArray(i)
Case Else
'Builds a string of mappings with
'the # as the delimiter
strBuild = strBuild & myArray(i) & "#"
End Select
Next
'Returns a 1-dimensinonal array based
'on the string i build existing values
strBuild = split(strBuild, "#")
'Clears current Script Mappings in the metabase
myValue.Put "ScriptMaps", VBNull
'Inserts values without un-needed mappings into metabase
myValue.Put "ScriptMaps", strBuild
myValue.SetInfo
set myValue = Nothing
end if
%>
jeg vil nu gerne have en kode hvor jeg bare sætter flueben i fx. ASP og så fjerner den ASP extension fra et angivent webhotel... men jeg har prøvet med nedenstående kode men det gider den bestemt ikke.. får bare en fejl der siger:
Error Type:
Microsoft VBScript compilation (0x800A03FE)
Expected 'Select'
/opretsys/mappingstest.asp, line 29, column 4
end if
<%
if request("mode") = opret then
Dim strExt
Dim myValue
dim strNothing
dim strBuild
dim i
dim iValue
Set myValue = GetObject("IIS://LocalHost/W3SVC/3/root")
'Returns an array multi valued list
'Puts the values in a local array variable myArray
myArray = myValue.Get("ScriptMaps")
'Loops through building a string
'based on myArray list of values
For i = 0 To UBound(myArray)
iValue = InStr(myArray(i), ",")
strExt = Left(myArray(i), iValue - 1)
if request.querystring("php") = "ON" then
Select Case strExt
Case ".php", ".phtml", ".php3", ".php4"
end if
if request.querystring("asp") = "ON" then
Select Case strExt
Case ".asp"
end if
'Builds a bogus string of un-needed mappings
strNothing = strNothing & myArray(i)
Case Else
'Builds a string of mappings with
'the # as the delimiter
strBuild = strBuild & myArray(i) & "#"
End Select
Next
'Returns a 1-dimensinonal array based
'on the string i build existing values
strBuild = split(strBuild, "#")
'Clears current Script Mappings in the metabase
myValue.Put "ScriptMaps", VBNull
'Inserts values without un-needed mappings into metabase
myValue.Put "ScriptMaps", strBuild
myValue.SetInfo
set myValue = Nothing
end if
%>
jeg har dog hørt noget med at det er fordi man ikke må sætte if sætninger inde mit i koden ... men jeg kan ikke finde ud af hvordan det ellers skal gøre :(.. håber der er en der kan hjælpe mig med at løse problemet :)
MVH
Kasper
