Oversæt fra ASP til PHP
Hej jeg har noget ASP som jeg skal have oversat til PHP. Da jeg ikke fatter PHP er det en hel oversættelse jeg søger.Dato = "020416" 'Dato i ÅÅMMDD
arrMonth = Array("januar", "febuar", "marts", "april", "maj", "juni", "juli", "august", "september", "oktober", "november", "december")
arrDay = Array("søndag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag")
Dim fs, f, fc ,sti
set fs = CreateObject("Scripting.FileSystemObject")
set f = fs.GetFolder(Server.MapPath("/media/billedgalleri"))
Set fc = f.SubFolders
Dim theFiles( )
ReDim theFiles( 500 ) ' arbitrary size!
currentSlot = -1 ' start before first slot
For Each fileItem in fc
fname = fileItem.Name
fcreate = fileItem.DateCreated
currentSlot = currentSlot + 1
If currentSlot > UBound( theFiles ) Then
ReDim Preserve theFiles( currentSlot + 99 )
End If
' note that what we put here is an array!
theFiles(currentSlot) = Array(fname,fcreate)
Next
fileCount = currentSlot ' actually, count is 1 more, since we start at 0
ReDim Preserve theFiles( currentSlot ) ' really not necessary...just neater!
'Sortby: 1=oprettet, 0=dato
'kind: 1,2=string sort, 3,3=dato sort
if Request("sortby")="c" then
'Sorter efter dato som billeder er lagt op
kind = 3
sortby=1
else
'Sorter efter billedernes dato
kind = 1
sortby=0
end if
For i = fileCount TO 0 Step -1
minmax = theFiles( 0 )( sortBy )
minmaxSlot = 0
For j = 1 To i
Select Case kind ' which kind of sort are we doing?
' after the "is bigger/smaller" test (as appropriate),
' mark will be true if we need to "remember" this slot...
Case 1 ' string, reverse...we do case INsensitive!
mark = (strComp( theFiles(j)(sortBy), minmax, vbTextCompare ) < 0)
Case 2 ' string, forward...we do case INsensitive!
mark = (strComp( theFiles(j)(sortBy), minmax, vbTextCompare ) > 0)
Case 3 ' non-string, reverse ...
mark = (theFiles( j )( sortBy ) < minmax)
Case 4 ' non-string, forward ...
mark = (theFiles( j )( sortBy ) > minmax)
End Select
' so is the current slot bigger/smaller than the remembered one?
If mark Then
' yep, so remember this one instead!
minmax = theFiles( j )( sortBy )
minmaxSlot = j
End If
Next
' is the last slot the min (or max), as it should be?
If minmaxSlot <> i Then
' nope...so do the needed swap...
temp = theFiles( minmaxSlot )
theFiles( minmaxSlot ) = theFiles( i )
theFiles( i ) = temp
End If
Next
' Ta-da! The array is sorted!
For i = 0 To fileCount
Dato = Mid(theFiles(i)(0),1,6)
datoStr = Mid(Dato,5,2) & "-" & Mid(Dato,3,2) & "-" & Mid(Dato,1,2)
datoDag = Mid(Dato,5,2)
if InStr(1,datoDag,"0") = 1 then
datoDag = Mid(Dato,6,1)
end if
datoStreng = arrDay(WeekDay(datoStr)-1) & " d. " & datoDag & ". " & arrMonth(CInt(Mid(Dato,3,2))-1) & " 20" &(Mid(Dato,1,2))
%>
<tr>
<td width="50%"><p align="right"><b><%=Mid(theFiles(i)(0),8) %></b><br><%=datoStreng%><br>oprettet <%=theFiles(i)(1)%></td>
<td width="50%"><a href="billedgalleri_detaljeret.asp?sti=<%=theFiles(i)(0)%>" > <p align="left"><img src="../media/billedgalleri/<%=theFiles(i)(0)%>/thumbnails/index.jpg" border="1" align="left"></a></td>
</tr>
<%
Next
%>
