file clicks.asp
codice:
<%
' Value for the url being requested
url=trim(request.querystring("url"))
' if no url is detected then show then
' show a page with links
if url="" then %>
<html>
<title>CodeAve.com(Count Clicks to a Db)</title>
<head>
<base target="_blank">
</head>
<body bgcolor="#FFFFFF">
Yahoo
AOL
Excite
Mail2Web
ASPIn
SAS
</body>
</html>
<%
' if there is a url value detected add it to the db
' and redirect the browser to the url
else
%>
<%
' Varible for the PC IP address
ip=request.servervariables("remote_addr")
' name of the db that will track the clicks
accessdb="/calagavetta.it/mdb-database/clienti.mdb"
' Build a connection to the db
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
' Create a server record set object
set rs = server.createobject("ADODB.Recordset")
' SQL statement that will insert the url and the ip address
sql = "insert into clicks (url,ip) values('"& url &"','"& ip &"')"
' insert the values into the db
rs.open sql, cn
' kill the recordset
set rs=nothing
' redirect to the url
response.redirect url
%>
<% end if ' end check for a url value %>
file click_view.asp
codice:
<html>
<title>CodeAve.com(Click Through Display)</title>
<body bgcolor="#FFFFFF">
<%' Check to see if there is any input
' if not display the form for input
u_input=request.form("u_input")
%>
<center>
<form action="<%= request.servervariables("script_name")%>" method="post">
<input type="submit" value="View">
<% if u_input <> "" then %>
Clicks by
<% else %>
Select a Report
<% end if %>
<select size="1" name="u_input">
<option <% if u_input="URL" then response.write
"selected " end if %>value="URL">URL</option>
<option <% if u_input="Day" then response.write
"selected " end if %>value="Day">Day</option>
<option <% if u_input="Month" then response.write
"selected " end if %>value="Month">Month</option>
<option <% if u_input="IP" then response.write
"selected " end if %>value="IP">IP</option>
</select>
</form>
</center>
<%' When there is input display the data
if u_input <> "" then
' Name of the Access db
accessdb="/calagavetta.it/mdb-database/clienti"
' Connection to the db
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
' Create a server record set object
set rs = server.createobject("ADODB.Recordset")
sql = "Clicks_by_" & u_input
' Execute the sql
rs.Open sql, cn
%>
<table border=3 align=center>
<tr>
<% ' Write out all the elements requested in the
' sql statement as table headers
for each element in rs.fields%>
<th><%= ucase(element.name) %></th>
<% next
' End table headers %>
</tr>
<tr>
<% ' Write out all the values in the record
do while not rs.eof
for each element in rs.fields %>
<td align=left><%= rs(element.name) %></td>
<%
next
' end of record %>
</tr>
<% ' Move to the next record
rs.movenext
' Loop to the beginning
loop%>
</table>
<% end if 'End check for user input %>
</body>
</html>