Hi, I have this very nice link tracker script that works a treat.
The only thing is it doesnt restrict repeat clicking.
Is there a simple method to add a cookie feature to this so that people cannot vote twice. I prefer cookies over ip recording. Any pointers would be a great help. -
%@ Language=VBScript %>
-
<%
-
Option Explicit ' Never code without it!
-
Response.Buffer = True ' Make sure we can redirect later
-
-
' The constants I use in this script...
-
' pulled directly from adovbs.inc
-
Const adOpenForwardOnly = 0
-
Const adOpenDynamic = 2
-
Const adLockReadOnly = 1
-
Const adLockPessimistic = 2
-
Const adCmdText = &H0001
-
-
' This needs to be ' for SQL Server and # for Access
-
Const DATE_DELIMITER = "#"
-
-
Dim strName ' Friendlyname of the redirect
-
Dim strId ' id the redirect
-
Dim cnnLinkTracker ' ADO objects
-
Dim rsLinkTracker
-
Dim strSQL ' SQL command building area
-
Dim iRedirectId ' id of the redirect for logging process
-
-
' Get name of location to go to
-
' I simply call this name so to call the script it would look
-
' something like this:
-
' http://server/linktracker.asp?id=asp101
-
' where asp101 is the friendly id from the database
-
strId = Request.QueryString("id")
-
-
' Make it DB friendly just in case a ' got in somehow
-
strId = Replace(strId, "'", "''")
-
-
' Create a new connection
-
Set cnnLinkTracker = Server.CreateObject("ADODB.Connection")
-
-
' Your connection string goes here!
-
' This one expects an Access database in the same place as this script
-
cnnLinkTracker.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
-
Server.MapPath("/xxxxxxxxxxxx"), "", ""
-
-
' Create a recordset
-
Set rsLinkTracker = Server.CreateObject("ADODB.Recordset")
-
-
' Get the record we're looking for by passing it the name
-
' we got from the QueryString. I'm prebuilding the SQL command
-
' to make it easier to debug if we need to.
-
strSQL = "SELECT PostCard, Headline FROM tblGreet " & _
-
"WHERE PostCardID=" & strId & ";"
-
' Quick and dirty debugging when something goes wrong.
-
'Response.Write strSQL
-
-
' Send the command to the database to get the appropriate records
-
rsLinkTracker.Open strSQL, cnnLinkTracker, _
-
adOpenForwardOnly, adLockReadOnly, adCmdText
-
-
' If we got back any results then we know where to send them
-
' o/w I just send them to our home page for lack of a better
-
' place to send them.
-
If Not rsLinkTracker.EOF Then
-
' Get redirect Id # from recordset
-
iRedirectId = rsLinkTracker.Fields("PostCard").Value
-
-
' Get location to send the user to
-
strName = rsLinkTracker.Fields("Headline").Value
-
-
' We've got all the info we need so close our recordset
-
rsLinkTracker.Close
-
-
' I now recycle the recordset for the logging process.
-
' Lots of people would argue with me about this, but I
-
' know I'm doing it and this is my code so if you don't
-
' like it feel free to change it, but I'm not going to!
-
-
' Start logging process
-
-
' Build out SQL String ahead of time.
-
' This should get us the record containing the information
-
' for the selected link for today's date if one exists.
-
strSQL = "SELECT link_id, hit_date, hit_count " & _
-
"FROM tblLinkTrackerLog " & _
-
"WHERE link_id = " & iRedirectId & " " & _
-
"AND hit_date = " & DATE_DELIMITER & Date() & DATE_DELIMITER
-
-
' Standard debugging step when something goes wrong!
-
'Response.Write strSQL
-
-
' Send the command.
-
rsLinkTracker.Open strSQL, cnnLinkTracker, _
-
adOpenDynamic, adLockPessimistic, adCmdText
-
-
' If it's EOF then it's the first hit of the day and we need
-
' to add a new record o/w we simply update the existing hit
-
' count of the record by adding one to it.
-
If rsLinkTracker.EOF Then
-
rsLinkTracker.AddNew
-
-
rsLinkTracker.Fields("link_id").Value = iRedirectId
-
rsLinkTracker.Fields("hit_date").Value = Date()
-
rsLinkTracker.Fields("hit_count").Value = 1
-
Else
-
rsLinkTracker.Fields("hit_count").Value = _
-
rsLinkTracker.Fields("hit_count").Value + 1
-
End If
-
-
' Save changes to the data
-
rsLinkTracker.Update
-
Else
-
' If no match send em to our home page
-
strName = "/"
-
End If
-
-
' Close our recordset object
-
rsLinkTracker.Close
-
Set rsLinkTracker = Nothing
-
-
' Kill our connection
-
cnnLinkTracker.Close
-
Set cnnLinkTracker = Nothing
-
-
' Send them on their merry way using the location we got
-
' from the database!
-
Response.Redirect "http://" & strName
-
%>
Thanks
Richard
2 1627
Hi, I got this cookie if clause done but it doesnt seem to work. I mean it doesnt stop someone clicking 100 times, it will record all 100. It is meant to, with the use of the cookie to stop after the first. Can anyone see why? Any help would be great.
Thanks
Richard - ' Send the command.
-
rsLinkTracker.Open strSQL, cnnLinkTracker, _
-
adOpenDynamic, adLockPessimistic, adCmdText
-
-
'Establish cookie for unique hit Counting
-
-
Response.Cookies("Visited").Expires=date+1
-
strVisited = Request.Cookies("Visited")
-
-
' If it's EOF then it's the first hit of the day and we need
-
' to add a new record o/w we simply update the existing hit
-
' count of the record by adding one to it.
-
-
If rsLinkTracker.EOF Then
-
rsLinkTracker.AddNew
-
-
rsLinkTracker.Fields("link_id").Value = iRedirectId
-
rsLinkTracker.Fields("hit_date").Value = Date()
-
rsLinkTracker.Fields("hit_count").Value = 1
-
-
Response.Cookies("Visited") = "yes"
-
' Save changes to the data
-
rsLinkTracker.Update
-
Else
-
If strVisited = "" Then
-
Response.Cookies("Visited") = "yes"
-
'Increment the visitor counter number by 1
-
rsLinkTracker.Fields("hit_count").Value + 1
-
' Save changes to the data
-
rsLinkTracker.Update
-
End If
-
End If
jhardman 3,406
Recognized Expert Specialist
How do you check when you record votes whether they have the cookie?
Jared
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mark |
last post by:
I am designing a game for a forum. When the user has finished playing
I need to save their data to a cookie then navigate to a page which
holds their score data (I can't have both sets of data on the same
page because I can't control the forum design). The score data is
updated with the results held in the cookie and the cookie is deleted.
I need to stop the user just typing for example
javascript:document.cookie="myScore=1000000" into the...
|
by: Andrew Phillipo |
last post by:
I have a layout which works perfectly. It is three column, the central
column is width:auto; with margins and the columns are absolutely
positioned at top:0px; left:0px; and top:0px;right:0px;
In the right column I have a javascript link which hides the column.
This is very necessary due to the width of content shown on the site at
times.
Clicking the link makes the scrollbars appear for no aparent reason -
both horizontal by about...
|
by: Jeroen Ceuppens |
last post by:
I need a selection tracker on a graphic
Idea:
left click: rectangle appear en grows when you move the mouse, again
clicking is lock te rectangle
How do you do that?
Greetz
Jeroen
|
by: Daniel Michaeloff |
last post by:
Hi all,
I have an application that when finished redirects to a non-ASP.NET app
which is choking on a huge ASP.NET session cookie. The cookie
"ASP.NET_SessionId" gets transmitted by the browser (IE6 in test case)
despite trying Microsoft's suggested method of expiring the cookie first.
I'd like to be able to kill the cookie and do a Response.Redirect() from
within a server-side button handler, but I'm to the point now where I'm...
|
by: Giovanni Bajo |
last post by:
Hello,
I just read this mail by Brett Cannon:
http://mail.python.org/pipermail/python-dev/2006-October/069139.html
where the "PSF infrastracture committee", after weeks of evaluation, recommends
using a non open source tracker (called JIRA - never heard before of course)
for Python itself.
Does this smell "Bitkeeper fiasco" to anyone else than me?
--
| |
by: yangsuli |
last post by:
i want to creat a link
when somebody click the link
the php script calls a function,then display itself :)
i have tried
<a href=<? funtion(); echo=$_server ?>text</a>
but it will call the function whether i click the link
then i tried this (using forms)
|
by: Nanker |
last post by:
In our .NET 1.1 ASP.NET application, I'm noticing some behavior that I
would like to change. If I open a web browser and manually copy and
paste a URL, then I get a new session ID (I check it by entering
javascript:document.cookie in the URL field to get the cookies for the
page). However, if I instead click on the same URL in an email link,
the browser that is opened will reuse the session ID if another browser
is already open to the...
|
by: monomaniac21 |
last post by:
hi
i have a php site which allows users to save a cookie on their
computer which stores their user id details and allows them to auto-
login.
i'm wondering whether this is safe, is it possible for a malicious
user to find that cookie and change its value and therefore auto-login
as someone else? and if so how can this be prevented?
|
by: MangroveRoot |
last post by:
Hi all ...
I've been learning and using PHP for a couple months now,
working on a couple of somewhat different sites.
On one site, I have a page with a form,
and that form includes a couple of ACTION=SUBMIT buttons,
so that clicking either button will immediately reload the page
only with an argument tacked on, e.g. "?size=128" or "?size=256".
This causes some images to be resized,
but otherwise the page appears the same.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |