Der er dog et lille problem.
Prøv at se her:
http://www.darkzone.dk/backup/mdaemon_backup.aspDet er koden herunder der bruges. Der virker selve if strukturen ik. Den er altid grøn! Hvorfor det?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Mdaemon backup</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body bgcolor="#232323">
<table border="0" width="100%">
<tr>
<td class="text1">
<p align="center"><span style="font-size: 12pt; font-weight:700">-=[@
Mdaemon backup log @]=-</span></td>
</tr>
</table>
<%
logfilSti = "daglig_mdaemon_log/" 'slut med /
set fso = Server.CreateObject("Scripting.Filesystemobject")
Set f = fso.GetFolder(Server.Mappath(logfilSti))
Set fc = f.Files
redim logfilArray (f.files.count,1)
i = 0
For Each fil in fc
if inStr(1,"txt,log",LCase(fso.GetExtensionName(fil.name))) > 0 then
logfilArray(i,0) = fil.name
logfilArray(i,1) = fil.DateLastModified
i=i+1
end if
next
'Sorter filerne
Call QuickSort(logfilArray,lbound(logfilArray),ubound(logfilArray),1,"DESC")
for i = lbound(logfilArray) to ubound(logfilArray)
if logfilArray(i,0) <> "" and logfilArray(i,1) <> "" then
Set filen = fso.OpenTextFile(Server.Mappath(logfilSti&logfilArray(i,0)),1)
tmp = filen.ReadAll
filen.Close
set filen = Nothing
if instr(1, tmp, "Warning", 1) > 0 then
response.write "<span style=""color:red""><img border=""0"" src=""firkantr.GIF"" width=""25"" height=""15""></span> : "
elseif instr(1, tmp, "Warning", 1) > 0 or instr(1, tmp, "skipped", 1) > 0 or instr(1, tmp, "in use", 1) > 0 then
response.write "<span style=""color:yellow""><img border=""0"" src=""firkantgul.GIF"" width=""25"" height=""15""></span> : "
else
response.write "<span style=""color:green""><img border=""0"" src=""firkantg.GIF"" width=""25"" height=""15""></span> : "
end if
response.write "<a class=""text1"" href=""" & logfilSti&logfilArray(i,0) & """>"
response.write logfilArray(i,0) & "<a>"
response.write "<br>"
end if
next
set fc = Nothing
set f = Nothing
set fso = Nothing
%>
</body>
</html>
<%
' Sorterings funktioner
Sub SwapRows(ary,row1,row2)
Dim x,tempvar
For x = 0 to Ubound(ary,2)
tempvar = ary(row1,x)
ary(row1,x) = ary(row2,x)
ary(row2,x) = tempvar
Next
End Sub
function FormatCompare(sOne,sTwo)
if (isNumeric(Trim(sOne)) AND isNumeric(Trim(sTwo))) then
FormatCompare = CDbl(Trim(sOne))
elseif (isDate(Trim(sOne)) AND isDate(Trim(sTwo))) then
FormatCompare = CDate(Trim(sOne))
else
FormatCompare = Trim(sOne)
end if
end function
Sub QuickSort(vec,loBound,hiBound,SortField,SortDir)
'==--------------------------------------------------------==
'== Sort a multi dimensional array on SortField ==
'== ==
'== This procedure is adapted from the algorithm given in: ==
'== ~ Data Abstractions & Structures using C++ by ~ ==
'== ~ Mark Headington and David Riley, pg. 586 ~ ==
'== Quicksort is the fastest array sorting routine for ==
'== unordered arrays. Its big O is n log n ==
'== ==
'== Parameters: ==
'== vec - array to be sorted ==
'== SortField - The field to sort on (1st dimension value) ==
'== loBound and hiBound are simply the upper and lower ==
'== bounds of the array's "row" dimension. It's probably ==
'== easiest to use the LBound and UBound functions to ==
'== set these. ==
'== SortDir - ASC, ascending; DESC, Descending ==
'==--------------------------------------------------------==
if not (hiBound - loBound = 0) then
Dim pivot(),loSwap,hiSwap,temp,counter
Redim pivot (Ubound(vec,2))
SortDir = UCase(SortDir)
'== Two items to sort
if hiBound - loBound = 1 then
if (SortDir = "ASC") then
if FormatCompare(vec(loBound,SortField),vec(hiBound,SortField)) > FormatCompare(vec(hiBound,SortField),vec(loBound,SortField)) then Call SwapRows(vec,hiBound,loBound)
else
if FormatCompare(vec(loBound,SortField),vec(hiBound,SortField)) < FormatCompare(vec(hiBound,SortField),vec(loBound,SortField)) then Call SwapRows(vec,hiBound,loBound)
end if
End If
'== Three or more items to sort
For counter = 0 to Ubound(vec,2)
pivot(counter) = vec(int((loBound + hiBound) / 2),counter)
vec(int((loBound + hiBound) / 2),counter) = vec(loBound,counter)
vec(loBound,counter) = pivot(counter)
Next
loSwap = loBound + 1
hiSwap = hiBound
do
'== Find the right loSwap
if (SortDir = "ASC") then
while loSwap < hiSwap and FormatCompare(vec(loSwap,SortField),pivot(SortField)) <= FormatCompare(pivot(SortField),vec(loSwap,SortField))
loSwap = loSwap + 1
wend
else
while loSwap < hiSwap and FormatCompare(vec(loSwap,SortField),pivot(SortField)) >= FormatCompare(pivot(SortField),vec(loSwap,SortField))
loSwap = loSwap + 1
wend
end if
'== Find the right hiSwap
if (SortDir = "ASC") then
while FormatCompare(vec(hiSwap,SortField),pivot(SortField)) > FormatCompare(pivot(SortField),vec(hiSwap,SortField))
hiSwap = hiSwap - 1
wend
else
while FormatCompare(vec(hiSwap,SortField),pivot(SortField)) < FormatCompare(pivot(SortField),vec(hiSwap,SortField))
hiSwap = hiSwap - 1
wend
end if
'== Swap values if loSwap is less then hiSwap
if loSwap < hiSwap then Call SwapRows(vec,loSwap,hiSwap)
loop while loSwap < hiSwap
For counter = 0 to Ubound(vec,2)
vec(loBound,counter) = vec(hiSwap,counter)
vec(hiSwap,counter) = pivot(counter)
Next
'== Recursively call function .. the beauty of Quicksort
'== 2 or more items in first section
if loBound < (hiSwap - 1) then Call QuickSort(vec,loBound,hiSwap-1,SortField,SortDir)
'== 2 or more items in second section
if hiSwap + 1 < hibound then Call QuickSort(vec,hiSwap+1,hiBound,SortField,SortDir)
end if
End Sub 'QuickSort
%>