ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 27th, 2005, 01:48 PM
jmeeter's Avatar
jmeeter jmeeter is offline
EXOH
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Nov 2004
Location: corner of methadone and disillusionment
Posts: 1,040 jmeeter User rank is Sergeant Major (2000 - 5000 Reputation Level)jmeeter User rank is Sergeant Major (2000 - 5000 Reputation Level)jmeeter User rank is Sergeant Major (2000 - 5000 Reputation Level)jmeeter User rank is Sergeant Major (2000 - 5000 Reputation Level)jmeeter User rank is Sergeant Major (2000 - 5000 Reputation Level)jmeeter User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 6 Days 7 h 15 m 14 sec
Reputation Power: 45
Send a message via AIM to jmeeter Send a message via MSN to jmeeter
<cfcounter /> (counter script)

Okay, we are currently using a counter script that requires a custom tag (<cfcounter />). This works excellently, but we have come across a problem. What it does is creates a line of text in the code, like <!-- This page has been viewed 1000 times since Jan, 25, 2001. --> . The problem is, the date at the end updates every day. So today it would say April 27, 2005. And then tomorrow it will say April 28, 2005. My question is: What in the script is doing this? Does anyone have any ideas as to what will fix this? Thanks in advance.



PHP Code:
<!--- 
Cold Fusion Multipage Counter
Version 2.0
1
/26/01

Written by
:
Adam Stout (Adam@adamarkdesign.com)
ADAMARK Design
www
.adamarkdesign.com
    
This tag is free to 
use but please drop me a note to let me know you are using it.  If you have questions or comments email me atAdam@adamarkdesign.com

Version History
:
1.0 1/24/01
        Initial Release
2.0 
1/26/01
        I wrote then added a bunch of stuff
.  Checks and records IP of last user 
        to prevent reloads from incrementing counter
.  Also stores and displays 
        
if desired the date the counter was created.
    

PurposeCustom Tag That Can Be called from anywhere on the server
         
and will create a counter fill initialized to the number 
         you specify
.
         
Installation:     Place Counter.cfm in your custom tags directory.  Call the tag
                in your code with 
<CF_Counter>.  Done.

Required Attributes:
    
None

Optional Attributes
:
    
Start [Integer]    -- Initial counter to this number (used 1st time only) (Default is 5000)
    
Display [Yes/No] -- Whether to print counter visably or as a comment in the page (Default is Yes)
    
Date [Yes/No] -- Whether or not to display "since Date" (Default is No)
    
Mask [Date Mask] -- Date mask for Date if Displayed. (Default is "MMM D, YYYY")

Usage:

Ex1
    
<CF_Counter

    
ResultPrints 1000

Ex
2
    
<CF_Counter Display "No"
    
    
ResultPrints <!-- This page has been viewed 1000 times. -->
    
Ex
    
<CF_Counter Display "No" Start="5000"
    
    
ResultPrints <!-- This page has been viewed 5000 times. -->
    
Ex4
    
<CF_Counter Display "No" Date "Yes"
    
    
Result: <!-- This page has been viewed 1000 times since Jan252001. -->

--->

<
CFPARAM NAME="Display" DEFAULT="Yes"
<
CFPARAM NAME="Start" DEFAULT="1000">
<
CFPARAM NAME="Date" DEFAULT="Yes">
<
CFPARAM NAME="Mask" DEFAULT="MMM D, YYYY">

<
CFIF IsDefined("Attributes.Start")>
    <
CFSET Start #Attributes.Start#>
</CFIF>
<
CFIF IsDefined("Attributes.Display")>
    <
CFSET Display #Attributes.Display#>
</CFIF>
<
CFIF IsDefined("Attributes.Date")>
    <
CFSET Date #Attributes.Date#>
</CFIF>
<
CFIF IsDefined("Attributes.Mask")>
    <
CFSET Mask #Attributes.Mask#>
</CFIF>

<!--- 
Figure Out Where the Web Server Root is --->
<
CFSET Document_Root Left(CGI.PATH_TRANSLATED,Len(CGI.PATH_TRANSLATED)-Len(CGI.PATH_INFO))>

<!--- 
This is the Target Directory where you keep your counters --->
<
CFSET CounterFile DOCUMENT_ROOT "\Counters\" & Replace(CGI.PATH_INFO,"/", "_","ALL")>

<CFIF FileExists(Variables.CounterFile) IS "
False"> 
    <!--- Start Counter at 5000 --->
    <CFSET ReadThis = Start - 1 & "
" & "|" & DateFormat(Now())>
    <CFSET Initial = Start>
    
    <!--- Success Message --->
    <CFOUTPUT>
        Congrats. Your Counter File Successfully Created.<BR>
        Your counter has been initialized to #Initial#<BR>
        To change the counter simply modify the counter file:<BR>
        #CounterFile#<BR>
    </CFOUTPUT>
<CFELSE>
    <!--- Read Counter File --->
    <CFFILE ACTION="
READ" FILE="#CounterFile#" VARIABLE="ReadThis">
    
<CFSET FirstTime "Yes">
</
CFIF>

<!--- 
Seperate Last IPthe Count, and StartDate --->
<
CFSET Count ListGetAt(ReadThis,1,"|")>
<
CFSET LastIP ListGetAt(ReadThis,2,"|")>
<
CFSET CreateDate ListGetAt(ReadThis,3,"|")>

<!--- 
Increment Counter if not a repeat of the last IP --->
<
CFIF CGI.REMOTE_HOST NEQ LastIP>
    <
CFSET PageViews Count 1>
<
CFELSE>
    <
CFSET PageViews Count>
</
CFIF>

<!--- 
Display as comment ot text Display IS NOT "No" AND  --->
<
CFIF Display IS NOT "False">
    <
CFOUTPUT>
    
#PageViews#<CFIF Date IS "Yes"> since #DateFormat(CreateDate,Mask)#</CFIF>
    
</CFOUTPUT>
<
CFELSE>
    <
CFOUTPUT><!-- This page has been viewed #PageViews# times<CFIF Date IS "Yes"> since #DateFormat(CreateDate,Mask)#</CFIF>. --></CFOUTPUT>
</CFIF>

<!--- 
Set caller variables for use is wanted --->
<
CFSET Caller.PageViews PageViews>
<
CFSET Caller.CreateDate DateFormat(CreateDate,Mask)>

<!--- 
Record New Count and IP --->
<
CFSET WriteThis PageViews "|" CGI.REMOTE_HOST>

<!--- 
Insert Date if being initialized --->
<
CFIF IsDefined("FirstTime")>
    <
CFSET WriteThis WriteThis "|" DateFormat(Now())>
<
CFELSE>
    <
CFSET WriteThis WriteThis "|" CreateDate>
</
CFIF>

<!--- 
Output the text file --->
<
CFFILE ACTION="WRITE" FILE="#CounterFile#" OUTPUT="#WriteThis#" ADDNEWLINE="No"

Reply With Quote
  #2  
Old April 27th, 2005, 02:56 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,682 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 25 m 55 sec
Reputation Power: 53
I have to say that is incredibly complicated for just doing a counter. But anyway, as far as I can tell this is where it is reseting the date:

<CFSET ReadThis = Start - 1 & "| " & "|" & DateFormat(Now())>

But it should only be doing that if the file doesn't exist.

I'd think you might have a much easier time if you just scrap that tag and write a simple database query that reads and updates the count and the date in a database. Just my 2 cents.
Comments on this post
airdesign agrees!
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old May 7th, 2005, 03:12 AM
Alas's Avatar
Alas Alas is offline
Wickedwd.com
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: wickedwd.com
Posts: 187 Alas Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 17 h 32 m 22 sec
Reputation Power: 0
holy crap is that the complete code to an online auctioning ecommerce application?!!!!

Here man

Make your initial value in the database 0
then...

Code:
<CFSET Add1New = #PULLOUTTHEZERO# + 1> 

<CFQUERY DATASOURCE="#Datasource#">
  UPDATE Client
  SET TimesSeen = '#Add1New#'
  WHERE Whatever = '#Whatever#'
</CFQUERY>


That's it then just do a cfoutput youll see the current number of times the page was seen, itll keep adding 1 to the current number in the database

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > <cfcounter /> (counter script)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT