%
If InStr(Request.QueryString("handle"),"'") > 0 Or InStr(Request.QueryString("handle"),";") > 0 Or InStr(Request.QueryString("handle"),"""") > 0 Then
Response.Status = "400 BAD REQUEST"
Response.End
End If
blnInsecurePage = true
If Not Request.QueryString("random") = "" Then
strSQL = "SELECT DISTINCT handle FROM ba97_sectors_archive ORDER BY RAND() LIMIT 0,1"
adoRS.Open strSQL
Do While Not adoRS.EOF
Response.Redirect("/report.asp?handle=" & adoRS.fields("handle").value)
Loop
adoRS.Close
End If
strFilter = Trim(Left(Request.QueryString("filter"),4))
If strFilter = "" And Len(Request.QueryString("year")) = 4 Then
strFilter = Left(Request.QueryString("year"),4)
End If
%>
<% If Not Request.QueryString("handle") = "" Then %>
BA97 Calendar | Diary for <%= Left(Request.QueryString("handle"),32) %>
<% Else %>
BA97 Calendar | Others' Diaries
<% End If %>
<% If Not Request.ServerVariables("SERVER_NAME") = "localhost" Then %>
<%
End If
If Request.QueryString("handle") = "" Then
%>
<%
strSQL = "SELECT handle FROM ba97_users ORDER BY handle DESC"
adoRS.Open strSQL
Do While Not adoRS.EOF
strSearch = strSearch & "'" & LCase(adoRS.fields("handle").value) & "',"
adoRS.MoveNext
Loop
strSearch = Left(strSearch,Len(strSearch)-1)
adoRS.Close
%>
Whose diary do you want to view?
<% Else %>
<%
If Not Request.QueryString("handle") = "" Then
strUser = Left(Request.QueryString("handle"),32)
End If
strPermalink = "http://" & Request.ServerVariables("HTTP_HOST") _
& Request.ServerVariables("SCRIPT_NAME") & "?handle=" & strUser
If Not Request.QueryString("handle") = "" Then
strPermalink = strPermalink & "&year=" & strFilter
End If
%>
<%
strUser = Left(Request.QueryString("handle"),32)
strSQL = "SELECT sum(distance) 'distance', count(*) 'sectors' " _
& "FROM ba97_sectors " _
& "WHERE handle = '" & strUser & "'"
adoRS.Open strSQL
intUpcomingSectors = 0
intUpcomingDistance = 0
intTotalSectors = 0
intTotalDistance = 0
If Not adoRS.EOF Then
If Not adoRS.fields("sectors").value = "" Then intUpcomingSectors = CInt(adoRS.fields("sectors").value) End If
If Not adoRS.fields("distance").value = "" Then intUpcomingDistance = CDbl(adoRS.fields("distance").value) End If
End If
adoRS.Close
blnEditable = false
If strFilter = "" Then
strSQL = "SELECT flown_distance, sectors, DATE_FORMAT(first_sector, '%D %M %Y') 'first_sector' " _
& "FROM ba97_user_stats " _
& "WHERE handle = '" & strUser & "'"
adoRS.Open strSQL
If intUpcomingSectors > 0 Then intTotalSectors = CInt(intUpcomingSectors) End If
If intUpcomingDistance > 0 Then intTotalDistance = CDBl(intUpcomingDistance) End If
If Not adoRS.EOF Then
intTotalSectors = intTotalSectors + CInt(adoRS.fields("sectors").value)
intTotalDistance = intTotalDistance + CDBl(adoRS.fields("flown_distance").value)
End If
%>
<%= strUser %> has flown <%= FormatNumber(intTotalDistance-intUpcomingDistance,0) %> miles
<% If Not adoRS.EOF Then %>
in <%= adoRS.fields("sectors").value %> sectors since <%= adoRS.fields("first_sector").value %>.
<% Else %>
so far!
<% End If %>
<% If intUpcomingSectors > 0 Then %>
Including future bookings hidden & visible, that's <%= FormatNumber(intTotalDistance,0) %> miles in <%= intTotalSectors %> sectors.
<% End If %>
See their stats,
map or
retrospectives.
<%
adoRS.Close
'' Filtered Report
Else
strSQL = "SELECT sum(distance) 'flown_distance', count(*) 'sectors' " _
& "FROM ba97_sectors " _
& "WHERE handle = '" & strUser & "' " _
& "AND flight_date>='" & strFilter _
& "-01-01 00:00' AND flight_date<='" & strFilter _
& "-12-31 23:59' "
adoRS.Open strSQL
If Not adoRS.EOF Then
intTotalSectors = CDbl(adoRS.fields("sectors").value)
If Not adoRS.fields("flown_distance").value = "" Then
intTotalDistance = CDbl(adoRS.fields("flown_distance").value)
End If
End If
adoRS.Close
strSQL = "SELECT sum(distance) 'flown_distance', count(*) 'sectors' " _
& "FROM ba97_sectors_archive " _
& "WHERE handle = '" & strUser & "' " _
& "AND flight_date>='" & strFilter _
& "-01-01 00:00' AND flight_date<='" & strFilter _
& "-12-31 23:59' "
adoRS.Open strSQL
If Not adoRS.EOF Then
intTotalSectors = intTotalSectors + CInt(adoRS.fields("sectors").value)
If Not adoRS.fields("flown_distance").value = "" Then
intTotalDistance = intTotalDistance + CDbl(adoRS.fields("flown_distance").value)
End If
End If
adoRS.Close
%>
<%= strUser %> flew <%= FormatNumber(intTotalDistance,0) %>
miles over <%= intTotalSectors %> sectors in <%= strFilter %>.
See their stats,
map or
retrospective for that year.
<%
End If
%>
<%
strSQL = "SELECT at.*, a.airline_name " _
& "FROM ba97_airline_tiers at, ba97_airlines a, ba97_user_airline_link ual " _
& "WHERE at.airline_tier_id = ual.airline_tier_id " _
& "AND ual.handle = '" & strUser & "' " _
& "AND at.airline_identifier = a.airline_identifier"
adoRS.Open(strSQL)
If Not adoRS.EOF Then
arrLoyaltyCards = adoRS.GetRows
For intCount = 0 To UBound(arrLoyaltyCards,2)
Response.Write "