I used this ASP code a long time ago :) (2001... I guess)
-
I was just reviewing some of my old work in ASP...
I dont use ASP any longer, turned to PHP instead.
I use Delphi more often for off-line solutions.
Sorry for the big post... I am just curious :)
Actualy only global.asa is messy...
::: global.asa :::
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Function FilterDomain(s)
Dim p1, p2
p1 = InStr(1,s,"www.",0)
p2 = InStr(p1+1,s,".com",0)
If p1 = 0 Then
p1 = 1
Else
p1 = 5
End If
If p2 = 0 Then
p2 = Len(s) + 1
End If
FilterDomain = Mid(s, p1, p2 - p1)
End FunctionFunction RegSub(sStr, sExp, sRep)
Dim RegEx
Set RegEx = New RegExp
RegEx.Pattern = sExp
RegEx.IgnoreCase = True
RegEx.Global = True
RegSub = RegEx.Replace(sStr,sRep)
End FunctionSub Session_OnStart()
Dim s, sv, seOn Error Resume Next
If VarType(Application("local")) <> 8 Thense = Request.ServerVariables("SERVER_NAME")
's = RegSub(se, "[\D]", "")
'If s = "" Then
s = FilterDomain(se)
'End If'
Application("server") = s
If ((s="pc1") or (s="localhost") or (s="127.0.0.1")) Then
sv = "local"
Application("logpath") = "c:\webroot\mylogs\"
Application("counterfile") = Application("logpath") &"counter.txt"
Application("emailsfile") = Application("logpath") &"emails.txt"
Application("errorsfile") = Application("logpath") &"errors.txt"
Application("logfile") = Application("logpath") &"log"& right(year(now),2) & right(month(now)+100,2) & right(day+100,2) &".txt"
Application("db") = "c:\webroot\db\db.mdb"
Application("dbconn") = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Application("db") &";"
Application("mailserver") = "smtp.server.TLD"
Else
sv = "server"
Application("logpath") = "c:\aweb_apache\loja24com\mylogs\"
Application("counterfile") = Application("logpath") &"counter.txt"
Application("emailsfile") = Application("logpath") &"emails.txt"
Application("errorsfile") = Application("logpath") &"errors.txt"
Application("logfile") = Application("logpath") &"log"& Year(Date) & Right(Month(Date) + 100,2) & Right(Day(Date) + 100,2) &".txt"
Application("db") = "c:\server_path\db\db.mdb"
Application("dbconn") = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Application("db") &";"
Application("mailserver") = "smtp.hostserver.TLD"
End If
Application("local") = sv
Session.Timeout = 60
End If
End subSub Session_OnEnd()
Session.Contents.RemoveAll()
End sub</SCRIPT>
::: db.asp :::
<FONT size=2>Function FastOpenDBRef(SQL, FilePath, ByRef Dados)
Dim Conn, Erro, rs
On Error Resume Next
Err.Clear
Err = 0
Erro = 0
'Response.Write "FilePath : "& FilePath &"<br>"
'Response.Write "App(""conn"") : "& Application("dbconn") &"<br>"
Set Conn = Server.CreateObject("ADODB.Connection")
If FilePath = "" Then
Conn.Open Application("dbconn")
Else
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& FilePath &";"
End If
Set rs = Conn.Execute(SQL)
If (Err <> 0) Then
'Response.Write "Erro #"& Err &" : "& Err.Description &"<br><br>"
Erro = Err
Else
If (rs.eof) Then
Erro = 1
Else
Dados = rs.GetRows
End If
End If
rs.Close
Set rs = Nothing
Conn.Close
Set Conn = Nothing
FastOpenDBRef = Erro
End Function
</FONT>::: default.asp :::
(...)
Dim d
Dim name, img
SQL = "select f1,f2,f3,f4,f5 from table;"
<FONT size=2>If FastOpenDBRef(SQL,"",d) <> 0 Then
%>
No articles.
<%
Else
nr = UBound(d,2)
b = true
f = 0
Do While f <= nr
name = d(1,f)
img = d(2,f)
' test if is null ---> If IsNull(img) then img = ""
If b = false Then
' imagine a table with colored rows --> Response.Write " bgcolor=""#ffffff"""
Else
' imagine a table with colored rows --> Response.Write " bgcolor=""#f5f5f5"""
End If
Response.Write name & img
b = Not b
f = f + 1
Loop
<%
End If
</FONT>%>
This buffered contents seemed faster at the time, do you have used such technics ?
Or this is just one big WTF :D