|
Large resource site for webmasters with many FREE articles, tutorials, ASP applications, FAQ's, book and software reviews, forums, tools, services, and much, much more....... |
|
<%
' # THIS BLOCK IS USED TO SET HOW THE LINKS PAGE IS DISPLAYED.
' # PUT THIS ENTIRE CODE IN THE AREA YOU WANT THE DATA TO BE DISPLAYED.
' # DO NOT MODIFY THESE VARIABLES!
Dim SiteKey
Dim PageName
Dim nCols
Dim nPerPage
Dim NewWindow
Dim strPost
Dim strQuery
Dim ShowSearch
Dim strError
Dim strResult
Dim Cat
Dim strLan
' # YOU CAN MODIFY THE VARIABLES BELOW TO CUSTOMISE HOW THE CATALOG AND LINKS PAGES ARE DISPLAYED:
' # This sets the number of columns on the categories page.
' # Values between 1 and 10.
nCatCols = 2
' # This sets the number of columns on the links page.
' # Values either 1 and 2.
nLinksCols = 1
' # This vaiable sets the number of links on a page.
' # Values between 10 and 100.
nPerPage = 25
' # This variable controls whether a link opens in a new page.
' # Values are [1 = Yes, 0 = No]
NewWindow = 1
' # This search feature is not yet implemented
' # This vaiable controls whether a search box is displayed.
' # Values are [1 = Yes, 0 = No]
ShowSearch = 0
' # !!! IT IS IMPORTANT THAT NOTHING BELOW THIS LINE IS MODIFIED IN ANY WAY !!!
' -----------------------------------------------------------------------------
' # The following variables are sent to freelinkers.com to create the page
PageName = Request.ServerVariables("SCRIPT_NAME")
SiteKey = "88ff56a1-d763-4f70-a33a-76b45bf2c433"
strLan ="ASP"
' # Create the data to post to the freelinkers.com server
strPost = "&SiteKey=" & SiteKey
strPost = strPost & "&PageName=" & PageName
strPost = strPost & "&nLinksCols=" & nLinksCols
strPost = strPost & "&nCatCols=" & nCatCols
strPost = strPost & "&nPerPage=" & nPerPage
strPost = strPost & "&NewWindow=" & NewWindow
strPost = strPost & "&ShowSearch=" & ShowSearch
strPost = strPost & "&Lan=" & strLan
' # pass through any querystring data to freelinkers to allow paging
strQuery = Request.QueryString
Cat = Request.QueryString("cat")
' ---------------------------------------------------------------------------------
Function GetData(strQuery, strPost, ByRef strResponse, ByRef strError)
Dim hObj
Dim ComponentString
Set hObj = Nothing
On Error Resume Next
Set hObj = CreateObject("WinHttp.WinHttpRequest.5.1")
ComponentString = "" & vbCrLf
On Error Resume Next
If hObj Is Nothing Then
Set hObj = CreateObject("WinHttp.WinHttpRequest.5")
ComponentString = "" & vbCrLf
End If
On Error Resume Next
If hObj Is Nothing Then
If UseMSXML(strQuery, strPost, strResponse, strError) Then
' the MSXML function will return the data
GetData = True
Else
' we don't need to supply error information, since the error string
' is passed ByRef, the MSXML function will supply the data
GetData = False
End If
Else
hObj.Open "GET", "http://localhost/mylinks/port.aspx?" & strQuery & strPost, False
hObj.Send
If hObj.Status <> 200 Then
strError = "Error: Status=" & hObj.Status & " Text=" & hObj.ResponseText
GetData = False
Else
strResponse = ComponentString & hObj.responseText
GetData = True
End If
End If
End Function
Function UseMSXML(strQuery, strPost, ByRef strResponse, ByRef strError)
Dim hObj
Set hObj = Nothing
' let's see if the server supports the XMLHTTP component, various versions
On Error Resume Next
Set hObj = CreateObject("Msxml2.ServerXMLHTTP")
ComponentString = "" & vbCrLf
On Error Resume Next
If hObj Is Nothing Then
Set hObj = CreateObject("Msxml2.ServerXMLHTTP.4.0")
ComponentString = "" & vbCrLf
End If
On Error Resume Next
If hObj Is Nothing Then
Set hObj = CreateObject("Microsoft.XMLHTTP")
ComponentString = "" & vbCrLf
End If
On Error Resume Next
If hObj Is Nothing Then
strError = "No support for HTTP requests found."
UseMSXML = False
Else
' # Open connection to freelinkers.com, sending the WebsiteGuid information via POST
' # Also, pass through the querystring information (contains Cat, link information)
hObj.open "GET", "http://localhost/mylinks/port.aspx?" & strQuery & strPost, false
hObj.Send
If hObj.status <> 200 Then
' # there was an error!
strError = "Error: Status=" & hObj.status & " Text='" & hObj.responseText & "'"
UseMSXML = False
Else
strResponse = ComponentString & hObj.responseText
UseMSXML = True
End If
Set hObj = Nothing
End If
End Function
%>
<%=Request.ServerVariables("SERVER_NAME")%> <%=Cat%> Link Exchange
<%
If GetData(strQuery, strPost, strResult, strError) Then
Response.Write strResult
Else
' Error info in to the page. You may clean this up to
Response.Write strError
End If
%>
|