%
strPath=request("u")
%>
the automatic variable DIMer
<%if request("u")<>"" then%>
(you can copy this dimension statement and place it in your code, but this script DOES NOT affect any files it examines)
<%end if%>
enter the path name of an ASP page whose variables you'd like to dimension:
<% 'variable parse
'a script by Gus Mueller, April 6, 1999
if request("u")<>"" then
strPath=replace(strPath, "/", "\")
set objFSO = server.createobject("scripting.filesystemobject")
'response.write strpath
if objFSO.fileexists(server.mappath(strPath)) then
set filToolConfig = objFSO.opentextfile(server.mappath(strPath), 1, true)
if not filToolConfig.atendofstream then
strText = filToolConfig.readall
else
strText = ""
end if
filToolConfig.close
set filToolConfig=nothing
else
strText = ""
end if
if strText<>"" then
strText=NotScript(strText)
strText=GetASP(strText)
'strText=HTMLKill(strText)
strText= killComments(strText)
strText = replace(strText, "<" & "%", "")
strText = replace(strText, "%" & ">", "")
'response.write strText
if request("checker")<>"" then
strText=NotFunction(strText)
end if
'response.write strText
intCacheSize=1
redim arrCache(intCacheSize)
intStart=1
strText = replace(strText, chr(13), chr(10))
'strText = replace(strText, ")", ")" & chr(10))
do while instr(intStart, strText, "=")>0
intEqPos=instr(intStart, strText, "=")
intCRpos=instrrev(strText, chr(10), intEqPos)
if intCRPos=0 then intCRpos=1
'response.write intCRpos & " " & intEqPos-intCRpos
strExamine=mid(strText, intCRpos, intEqPos-intCRpos)
'response.write strExamine
if instr(1, strExamine, "elseif", 1 )=0 and instr(1, strExamine, "else ", 1 )=0 and (instr(1, strExamine, "if ", 1 )=0 or instr(1, strExamine, "then ", 1 )<>0 ) and instr(1, strExamine, "const ", 1) = 0 and instr(1, strExamine, "response.", 1) = 0 then
strExamine=replace(strExamine, "const ", "", 1, -1, 1)
strExamine=replace(strExamine, "instr(", "", 1, -1, 1)
strExamine=replace(strExamine, "isnull(", "", 1, -1, 1)
strExamine=replace(strExamine, "cstr(", "", 1, -1, 1)
strExamine=replace(strExamine, "cint(", "", 1, -1, 1)
strExamine=replace(strExamine, "left(", "", 1, -1, 1)
strExamine=replace(strExamine, "mid(", "", 1, -1, 1)
strExamine=replace(strExamine, "right(", "", 1, -1, 1)
strExamine=replace(strExamine, "end if", "", 1, -1, 1)
strExamine=replace(strExamine, "end function", "", 1, -1, 1)
strExamine=replace(strExamine, "if ", "", 1, -1, 1)
strExamine=replace(strExamine, "end ", "", 1, -1, 1)
strExamine=replace(strExamine, "%", "", 1, -1, 1)
strExamine=replace(strExamine, "case ", "", 1, -1, 1)
strExamine=replace(strExamine, "do ", "", 1, -1, 1)
strExamine=replace(strExamine, "while ", "", 1, -1, 1)
strExamine=replace(strExamine, "loop ", "", 1, -1, 1)
strExamine=replace(strExamine, "until ", "", 1, -1, 1)
strExamine=replace(strExamine, "for ", "", 1, -1, 1)
strExamine=replace(strExamine, "not ", "", 1, -1, 1)
strExamine=replace(strExamine, "set ", "", 1, -1, 1)
strExamine=replace(strExamine, "<", " ", 1, -1, 1)
strExamine=replace(strExamine, ">", " ", 1, -1, 1)
strExamine=trim(strExamine)
strExamine=replace(strExamine, vbTab, "")
strExamine=replace(strExamine, chr(10) , "")
strExamine=replace(strExamine, chr(13) , "")
'response.write strExamine & "*" & chr(13)
if strExamine=" " then strExamine=""
if isVariable(strExamine) then
if instr(strExamine, "(") then
strExamine=left(strExamine, instr(strExamine, "(")-1)
end if
if instr(strExamine, ",") then
strExamine=left(strExamine, instr(strExamine, ",")-1)
end if
if instr(strExamine, chr(34)) then
strExamine=left(strExamine, instr(strExamine, chr(34))-1)
end if
if instr(strExamine, "=") then
strExamine=left(strExamine, instr(strExamine, "=")-1)
end if
if instr(strExamine, " ") then
strExamine=left(strExamine, instr(strExamine, " ")-1)
end if
if instr(strExamine, "then") then
strExamine=left(strExamine, instr(strExamine, "then")-1)
end if
if instr(strExamine, ".") then
strExamine=left(strExamine, instr(strExamine, ".")-1)
end if
intOver=0
for intLocalScan=0 to intCacheSize
if lcase(arrCache(intLocalScan))=lcase(ArrayFlatten(strExamine)) then
intOver=intOver+1
end if
next
if intOver=0 then
for intLocalScan = 0 to intCacheSize-1
arrCache(intLocalScan)=arrCache(intLocalScan+1)
next
arrCache(intCacheSize)=strExamine
strCollect = strCollect & strExamine & chr(13)
intCount=intCount+1
end if
end if
end if
intStart=intEqPos+1
loop
arrCollect=split(strCollect, chr(13))
intCollectMax=ubound(arrCollect)
'response.write strCollect
redim arrResult(ubound(arrCollect))
'time to sort that array
for intOuter=intCollectMax to 0 step-1
for intInner=0 to intOuter-1
if arrCollect(intInner)>arrCollect(intInner+1) then
strTemp=arrCollect(intInner+1)
arrCollect(intInner+1)=arrCollect(intInner)
arrCollect(intInner)=strTemp
end if
next
next
intCount=0
redim arrCache(intCacheSize)
for intArrayScan=0 to intCollectMax
intOver=0
for intLocalScan=0 to intCacheSize
if lcase(arrCache(intLocalScan))=lcase(arrCollect(intArrayScan)) then
intOver=intOver+1
end if
next
if intOver=0 then
for intLocalScan = 0 to intCacheSize-1
arrCache(intLocalScan)=arrCache(intLocalScan+1)
next
arrCache(intCacheSize)=arrCollect(intArrayScan)
arrResult(intCount)=arrCollect(intArrayScan)
intCount=intCount+1
end if
next
intCoolCount=0
strProduce= "dim "
if intCount>ubound(arrResult) then intcount=ubound(arrResult)
for intArrayScan= 0 to intCount
if isVariable(NoBR(arrResult(intArrayScan))) then
strProduce= strProduce & NoBR(arrResult(intArrayScan))
if intCoolCount < intCount then strProduce= strProduce & (", ")
intCoolCount=intCoolCount+1
intCoolLen=intCoolLen + len(NoBR(arrResult(intArrayScan)) )
end if
if intCoolLen>50 and intCoolCount > 0 and intCoolCount < intCount-1 then
strProduce= strProduce & "_ " & chr(13)& chr(10) & vbTab
intCoolLen=0
end if
next
response.write "" & left(strProduce, len(strProduce)-2)
else
response.write "There was no file at the end of that path"
end if
end if
function HTMLkill(strIn)
'nukes the embedded HTML
do while instr(strIn, ">")>0
intTagStart=instr(strIn, "<")
intTagEnd=instr(intTagStart, strIn, ">")+1
strTag=mid(strIn, intTagStart, intTagEnd-intTagStart)
strIn= replace (strIn, strTag, "")
loop
strIn=replace(strIn, "<", "")
strIn=replace(strIn, ">", "")
HTMLkill=strIn
end function
function NoBR(strIn)
'kills that chr(10) type stuff
strIn=replace(strIn, chr(13), "")
NoBR=replace(strIn, chr(10), "")
NoBR=ArrayFlatten(NoBR)
end function
function isVariable(strIn)
'determines if this string could really be a variable under ASP
if strIn<>"" then
if strIn<>"else" and strIn<>"end" and StrIn<>"elseif" and StrIn<>"endif" and StrIn<>"instr" and StrIn<>"right" and StrIn<>"mid" and StrIn<>"cstr" and StrIn<>"int" and StrIn<>"cint" then
intFirst=asc(left(strIn, 1))
if intFirst>64 and intFirst<123 and intFirst<>95 then
isVariable=true
else
isVariable=false
end if
end if
end if
end function
function ArrayFlatten(strIn)
'removed dimension information from an array
intStart=1
do while instr(intStart, strIn, "(")>0
intTagStart=instr(intStart, strIn, "(")
intTagEnd=instr(intTagStart, strIn, ")")+1
if intTagEnd-intTagStart>0 then
strTag=mid(strIn, intTagStart, intTagEnd-intTagStart)
strIn= replace (strIn, strTag, "")
else
intStart=intTagStart+1
end if
loop
strIn=replace(strIn, "(", "")
strIn=replace(strIn, ")", "")
ArrayFlatten=strIn
end function
function NotScript(strIn)
'removes Javascripts from analysis
do while instr(1, strIn, "", 1)+9
strTag=mid(strIn, intTagStart, intTagEnd-intTagStart)
strIn= replace (strIn, strTag, "")
loop
strIn=replace(strIn, "