how did my file get corrupted? (+ how often to back up)

Post your Click counter digestion problems here
Post Reply
ladykatey
Posts: 2
Joined: Mon Oct 23, 2006 12:24 am

how did my file get corrupted? (+ how often to back up)

Post by ladykatey »

Script URL: http://www.timeforlight.com/ccount/index.php?
Version of script: 1.1
Hosting company: dreamhost
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:

Write your message below:

I've had the Click Counter installed for a relatively short amount of time- about two months. I only had seven links with a total of less than 500 clicks, and I just came home after a few days away and found that none of my links are working. I don't understand how the file could have corrupted itself.

Looking at it in my FTP program, the "clicks.txt" says it was last edited yesterday (while I was away.) The "ids.txt" file has a last edit date of sometime last week and only contains one character, so I assume it's corrupted too.

I'd like to better understand how this happened so I can prevent it in the future.

ps: how often should I back up the data? Is it only neccecary to backup when a new link is added, or should it need to be done more often?

pps: just had a thought. could robots crawling my site have overloaded the script and caused the loss of data?
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Hi,

It possible that by coincidence two users (or robots?) requested CCount link at the same time and that caused the clicks file to become corrupted. The ids.txt file SHOULD only contain one number inside and can only be written from within the admin panel, so that one should be OK.

I will be adding a function to lock files while writing to them in the next version of CCount which will (hopefully) prevent many causes for file corruption in the future.

As for making backups - do them as often as you think it's required. The more important info you have on your website the more often you should back everything up (not just CCount database). I have all my websites automatically backed up daily, it's much easier to sleep at night :wink:
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
ladykatey
Posts: 2
Joined: Mon Oct 23, 2006 12:24 am

Post by ladykatey »

thanks for the reply!
evagabond
Posts: 1
Joined: Mon Nov 27, 2006 1:48 am

clicks cleared

Post by evagabond »

Hello Klemen,

Firstly, thanks for the great script. I've been using it for over a year now and it has worked nearly flawlessly until now. Yesterday, I found all my established click counters gone... nearly 350 of them! Fortunately I did have a backup and restored it without difficulty.
My question is about what you mentioned to ladykatey,.. when two users click on the same link at the same time, it can delete all the saved data? It seems strange to me after using this for so long that this is what happened. Is there anything else could cause the data file to empty?
I'd like to continue using your script and might pay for your new (fixed) version when you release it. Please let me know if/when you do.
Thanks,
evagabond
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Hi,

Unfortunately that's the way it is with text databases - they are not powerful nor secure enough to work under load (several requests at the same time (can be for example clicks to different links, not the same one)).

I will be adding a file locking function to the next version of CCount which should prevent (most?) such cases, but I still suggest using a script with a MySQL database for anyone counting more than a few dozen links or with a lot of visitors.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply