Avatar billede netstuff.dk Nybegynder
21. marts 2002 - 14:55 Der er 8 kommentarer og
1 løsning

if sætninger i koden ? hva ellers ?

Hejsa allesammen

jeg 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
Avatar billede rou Nybegynder
21. marts 2002 - 14:59 #1
Fordi du har en fejlplaceret 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

%>
Avatar billede netstuff.dk Nybegynder
21. marts 2002 - 15:01 #2
det hjalp måske :).. jeg får nu fejlen:

Error Type:
Microsoft VBScript compilation (0x800A041F)
Unexpected 'Next'
/opretsys/mappingstest.asp, line 44
Next

og koden er lavet om til at se sådan ud :

<%
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"


if request.querystring("asp") = "ON" then

    Select Case strExt

    Case ".asp"

                    '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
%>
Avatar billede cms Nybegynder
21. marts 2002 - 19:45 #3
du mangler endnu en End Select som jeg ser det. Skal stå lige før Next.
Avatar billede netstuff.dk Nybegynder
21. marts 2002 - 23:39 #4
når jeg smider et "End Select" mere ind får jeg fejlen:

Error Type:
Microsoft VBScript compilation (0x800A03F4)
Expected 'If'
/opretsys/mappingstest.asp, line 44, column 4
End Select
---^
Avatar billede coltau Juniormester
22. marts 2002 - 14:11 #5
Er det ikke det her du søger. ?

<%
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"
                    '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
end if
if request.querystring("ASP") = "ON" then
    Select Case strExt

    Case ".asp"
                    '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
end if
               
               
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
%>
Avatar billede netstuff.dk Nybegynder
23. marts 2002 - 16:17 #6
nu begynder det hjælpe men hvis man skriver fil.asp?mode=opret så fjerner den ALLE script-mappings for HELE websitet... det skal jo være sådan at hvis man ikke sætter flueben i ASP eller PHP så skal den ikke gøre noget! :)

MVH
Kasper
Avatar billede coltau Juniormester
24. marts 2002 - 12:51 #7
Hvis det er checkboxe skal du ændre denne linie:
if request.querystring("php") = "ON" then
til:
if request.form("php") <> "" then

og så skal du sikre dig at checkboxen hedder php. Altså name="php"

Det samme skal gøres for ASP-linien.
Avatar billede coltau Juniormester
28. marts 2002 - 23:11 #8
Virker det eller hur ?
Avatar billede netstuff.dk Nybegynder
13. maj 2002 - 22:43 #9
det virker altså ikke!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester