> Why does it matter if someone already viewed
> the article?

I actually think that tracking page views and having time limits on counters
is a good approach if you have the time.  I run a link database that tracks
clicks on the links.  If someone clicks the same link more than once within
six hours, it only counts once.  In my situation links are marked as
"popular" of they are within the top 5% by clicks, so this helps prevent
people from clicking, hitting back, and clicking again multiple times to
inflate their rankings.  Clicks are tracked by IP, but I don't worry much
about proxy servers for this purpose.

Here's the code if the original poster can use it.  Watch for line wrapping.

-Justin



<!--- Delete any clicks more than six hours old. --->
<cfquery name="clickdelete" datasource="#request.dsn#">
        DELETE FROM click WHERE cliDateStamp <= DATEADD(hh, -6, getdate())
</cfquery>

<!--- Check to see if they've hit this link in the last six hours. --->
<cfquery name="clickcheck" datasource="#request.dsn#">
        SELECT cliID FROM click
        WHERE linID = <cfqueryparam cfsqltype="CF_SQL_INTEGER"
value="#links.linID#" />
        AND cliIP = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#cgi.remote_addr#" />
</cfquery>

<!--- If not found, update the count. --->
<cfif not clickcheck.recordcount>

        <cfquery name="updatecounters" datasource="#request.dsn#">
                UPDATE link SET
                        linHitCountCurrent = linHitCountCurrent + 1,
                        linHitCountTotal = linHitCountTotal + 1
                WHERE linID = <cfqueryparam cfsqltype="CF_SQL_INTEGER"
value="#links.linID#" />
        </cfquery>

        <!--- Add this to the click table. --->
        <cfquery name="clickinsert" datasource="#request.dsn#">
                INSERT INTO click VALUES (
                        <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#cgi.remote_addr#" />,
                        getdate(),
                        <cfqueryparam cfsqltype="CF_SQL_INTEGER"
value="#links.linID#" />
                )
        </cfquery>

</cfif> <!--- not clickcheck.recordcount --->



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:223079
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to