SunQuest
           Development Software
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementDevelopment Software

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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old December 25th, 2003, 12:50 AM
Tiradientes Tiradientes is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Nagoya, Japan
Posts: 1 Tiradientes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry Counter data deleted

Periodically, my counter data is deleted. I use the o****er on multiple pages (about 317 of them, to be exact), and every couple of days it reverts to 0 and starts counting again. I have no idea why this happens (not have I activated the "filk lock" function because I don't know what it does).
Any ideas? Here is the main code:

#!/usr/local/bin/perl
#
######################################################################
# Define Variables

# Data file path
my $data_file = "totals.txt";

# Lock file path
my $lock_file = "file.lock";

# Done
###################################

# Do count!
&count_num();

#####################
### Start of subs ###
#####################

##############
sub count_num{
##############
my $count_num;
print "Content-type: text/html", "\n\n";
&file_lock();
unless (open (FILE, "$data_file")){
print "[Sorry! Can't read from the counter data file]\n";
}
$count_num = <FILE>;
chop ($count_num);
close(FILE);
$count_num++;
unless (open (FILE, ">$data_file")){
print "[Can't write to the data file! Counter not incremented!]\n";
}
print FILE "$count_num\n";
close (FILE);
&file_unlock();

1 while $count_num =~ s/(.*\d)(\d\d\d)/$1,$2/;
print "$count_num\n";
}

######################
# File Locking
# Usage: &file_lock();
######################
sub file_lock{
my $i = 1;
while(-e $lock_file){
select(undef,undef,undef,0.1);
if (++$i>60) {
&file_unlock();
}
}
open(FILE,">$lock_file");
close(FILE);
}

########################
# File UnLocking
# Usage: &file_unlock();
########################
sub file_unlock{
unlink($lock_file);
}

#####################
### END OF SCRIPT ###
#####################

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementDevelopment Software > Counter data deleted


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 2 hosted by Hostway