#!/usr/bin/perl #----------------------- # ClickCount.cgi # Ver. 1.2.1 # 2000-11-12 # ---------------------- # Gustav Evertsson # www.guzzzt.com # me@guzzzt.com #----------------------- # # E. Hochawld 2003-04-27 changes: # Included last accessed date method. # accessible with "action=date" process # $logfile = "./logfile.txt"; $log = 'true'; $dbfile = "./clickcount.db"; &parse_query; if($ENV{'QUERY_STRING'} eq '') { print "Content-type: text/html\n\n"; # Print the top of the admin page print qq| GuzZzt ClickCount: Admin

GuzZzt ClickCount

|; # write all urls open(DATA, "$dbfile"); flock(DATA, 2); @db = ; @db = sort {$b <=> $a} @db; close(DATA); foreach (@db) { ($clicks, $url, $date, $name, $icon, $category) = split /\|/; $totclicks = $totclicks+$clicks; print qq| |; } #total clicks print qq| |; #Write the bottom of the page print qq|
URL Clicks Last Access Name Icon Category
$url $clicks $date $name $category
Total: $totclicks



Powered by GuzZzt ClickCount V. 1.2.1
Copyright 1999 Gustav Evertsson
From GuzZzt.com

|; } else{ if($query{'action'} eq 'jump') { $matchedcase = 'true'; open(DATA, "$dbfile"); flock(DATA, 2); @db = ; close(DATA); foreach (@db) { ($click, $url, $date, $name, $icon, $category) = split /\|/; if($url eq $query{'URL'}){ getdate($date); $newclick = $click+1; $dummy .= "$newclick|$url|$date|$name|$icon|$category|\n"; $find = 'true'; } else { $dummy .= "$click|$url|$date|$name|$icon|$category|\n"; } } if($find ne 'true') { getdate($date); $dummy .= "1|$query{'URL'}|$date|"; } open(DB, "+>$dbfile"); flock(DATA, 2); print DB $dummy; close(DB); print "Location: $query{'URL'} \n\n"; if ($log == 'true') { getdate($date); open (Da, ">> $logfile"); print Da "$date\|$ENV{'QUERY_STRING'}\|$ENV{'REMOTE_ADDR'}\|\n"; #$junk = `set`; #print Da "$junk\n"; close (Da); } } if($query{'action'} eq 'items') { $matchedcase = 'true'; open(DATA, "$dbfile"); flock(DATA, 2); @db = ; close(DATA); # print "Content-type: text/html\n\n"; # print ""; foreach (@db) { ($click, $url, $date, $name, $icon, $category) = split /\|/; print qq| |; } # print "
$category $click $name $date
"; } if($query{'action'} eq 'date') { $matchedcase = 'true'; open(DATA, "$dbfile"); flock(DATA, 2); @db = ; close(DATA); foreach (@db) { ($click, $url, $date, $name, $icon, $category) = split /\|/; if($url eq $query{'URL'}){ $viewdate = $date; $find = 'true'; } } if($find ne 'true') { $viewdate = "never"; } print "Content-type: text/html\n\n"; print "$viewdate"; } } if ($matchedcase ne 'true') { open(DATA, "$dbfile"); flock(DATA, 2); @db = ; close(DATA); foreach (@db) { ($click, $url, $date, $name, $icon, $category) = split /\|/; if($url eq $query{'URL'}){ $viewclick = $click; } } if($viewclick eq '') { $viewclick = 0; } print "Content-type: text/html\n\n"; print "$viewclick"; } sub parse_query { @pairs = split(/&/, $ENV{'QUERY_STRING'}); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ s/!/=/g; #change ! to = if double querystrings change all = to ! in the second url. $value =~ s/%/?/g; #change % to ? if double querystrings change all ? to % in the second url. $value =~ s//&/g; #change to & if double querystrings change all & to in the second url. $query{$name} = $value; } } sub getdate(){ @tempdate = localtime(time); $tempdate[5] += 1900; $tempdate[4] += 1; for ($j=0;$j<=4;$j++) { # for each of the months, days, hrs, mins & secs if ($tempdate[$j] <= 9) { # if the value is only a single digit $tempdate[$j] = "0$tempdate[$j]"; # pre-pend a leading 0 } } $date = "$tempdate[5]-$tempdate[4]-$tempdate[3] $tempdate[2]\:$tempdate[1]\:$tempdate[0]"; return($date); }
Sort by: