ERROR: invalid filename ".__FILE__; print "
\nmust be COUNTERNAME.cnt
"; exit; } $name = basename(__FILE__, '.cnt'); # del path and extension $file = "$dir/$name.i"; # the data file path // case you need customized configuration for specific counters, do it here // you can redefine $DEBUG, $report, $dir, $file, $owner and $reset // switch($name){ # specific configuration case 'txt2regex': { $report = 80; break; } case 'txt2tags' : { $report = 100; break; } case 'aurelio' : { $report = 450; break; } case 'funcoeszz': { $report = 80; break; } case 'sedsed' : { $report = 25; break; } case 'er' : { $report = 75; break; } case 'surf' : { $report = 50; break; } case 'rac' : { $report = 30; $owner.= ',thobiast@terra.com.br'; break; } } if (!is_file($file)) { addFrom("$reset:0"); exit ; } # creating data file debug("
");
			debug("component : $name");
			debug("file      : $file");
			debug("from URL  : $HTTP_REFERER");
			debug("from IP   : $REMOTE_ADDR");


$data = trim(getCount());              # get current count data
list($hits, $ip) = split(':', $data);  # separate in 2 vars


			debug("curr IP   : $ip");
			debug("curr count: $hits");

if ($REMOTE_ADDR != $ip) {             # different IP address, let's count!

    if ($hits%$report == 0){           # hey, we'll send report also!
  
			debug("*** email report time!");

        if ($mail_dir) {
    
			debug("*** email will be queued");
      
            # copy file to queue dir
	    copy($file, "$mail_dir/$name.".date("ymd-His"));
      
        } else {  

			debug("*** email will be sent");
	  
            # reading file to $body (this code SUX! how to do it oneliner?)
            $arr = file($file); $body = '';
            while (list ($trash, $line) = each ($arr)) $body.=$line;
      
            $subj = "-----  #$hits $name";     # set here the Subject: format
            mail($owner,$subj,$body);          # sending the message
      
			debug("*** email sent!");
        } 
    
        # cleaning data file contents because we've already sent the report
        $f = fopen($file,'w'); fclose($f);
    }
  
    $hits+=1;                            # adding count
    setCount("$hits:$REMOTE_ADDR");      # writing to data file
    if ($name == 'txt2tags')
        addFrom("- $REMOTE_ADDR/$HTTP_REFERER");    # temporary debug
    else	  
        addFrom("- $HTTP_REFERER");          # writing referer to data file
}


			debug("new count : $hits\n
"); print $hits; # showing count on page ?>