#!/usr/bin/perl ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $mon = $mon + 1; $pad_size = "2"; $mon_length = length($mon); for ($i = $pad_size;$i > $mon_length;$i--) { $mon = "0$mon"; } $mday_length = length($mday); for ($i = $pad_size;$i > $mday_length;$i--) { $mday = "0$mday"; } $year_length = length($year); if ($year_length<4) { if ($year>90&&$year<100) { $year = "19$year"; } else { $year = $year-100; $year_length = length($year); if ($year_length==1) { $year = "0$year"; } if ($year_length==0) { $year = "00"; } $year = "20$year"; } } $base_dir = "/home/shoutweb/shoutweb/hitcount/"; $banner_file = "http://www.shoutweb.com/hitcount/space.gif"; $count_file = "$base_dir$year$mon$mday.log"; $graph_file = "$count_file.graph"; $lock_file = "$count_file.lock"; $lock_sec = "10"; &check_lock($lock_sec); open(COUNT,"$count_file"); $count = ; close(COUNT); if ($count =~ /\n$/) { chop($count); } $count++; open(COUNT,">$count_file") || die "Can't Open Count Data File For Writing: $!\n"; print COUNT "$count"; close(COUNT); open (GRAPH,">>$graph_file") || die "Can't Open Graph Data File For Writing: $!\n"; print GRAPH "$hour\n"; close(GRAPH); &clean_up; print "Location: $banner_file\n\n"; sub check_lock { $time = $_[0]; for ($i = 1;$i <= $time; $i++) { if (-e "$lock_file") { sleep 1; } else { open(LOCK,">$lock_file"); print LOCK "0"; close(LOCK); last; } } } sub clean_up { unlink("$lock_file"); }