日期:2014-05-17 浏览次数:21072 次
smsvote.ini
---------------------------------
[smsvote]
server=(local)
db=smsvote
user=sa
password=123
[db2vote]
server=192.168.0.1
db=db2
user=sa
password=
<%
set inifiledictionary = createobject("scripting.dictionary")
sub inifileload(byval filspc)
inifiledictionary.removeall
filspc = lcase(filspc)
if left(filspc, 1) = "p" then
physical path
phypth = mid(filspc, instr(filspc, "=") + 1)
else
virtual path
phypth = server.mappath(mid(filspc, instr(filspc, "=") + 1))
end if
set filsys = createobject("scripting.filesystemobject")
set inifil = filsys.opentextfile(phypth, 1)
do while not inifil.atendofstream
strbuf = inifil.readline
if strbuf <> "" then
there is data on this line
if left(strbuf, 1) <> ";" then
its not a comment
if left(strbuf, 1) = "[" then
its a section header
hdrbuf = mid(strbuf, 2, len(strbuf) - 2)
else
its a value
strptr = instr(strbuf, "=")
altbuf = lcase(hdrbuf & " ¦" & left(strbuf, strptr - 1))
do while inifiledictionary.exists(altbuf)
altbuf = altbuf & "_"
loop
inifiledictionary.add altbuf, mid(strbuf, strptr + 1)
end if
end if
end if
loop
inifil.close
set inifil = nothing
set filsys = nothing
end sub
function inifilevalue(byval valspc)
dim ifarray
strptr = instr(valspc, " ¦")
valspc = lcase(valspc)
if strptr = 0 then
they want the whole section
strbuf = ""
strptr = len(valspc) + 1
valspc = valspc + " ¦"
ifarray = inifiledictionary.keys
for i = 0 to inifiledictionary.count - 1
if left(ifarray(i), strptr) = valspc then
this is from the section
if strbuf <> "" then
strbuf = strbuf & "~"
end if
strbuf = strbuf & ifarray(i) & "=" & inifiledictionary(ifarray(i))
end if
next
else
they want a specific value
strbuf = inifiledictionary(valspc)
end if
inifilevalue = strbuf
end function
function chr(section,key)
char1=inifilevalue(section)
searchstring =char1
searchchar = key
mypos=instr(1,searchstring,searchchar,1)
char2=section+key
char1=mid(char1,mypos+len(key)+1,len(char1)-mypos+1)
searchstring =char1
searchchar = "~"
mypos