#!/usr/bin/perl
##############################################################################
# You must modify the the location of PERL in the first line above to match  #
# the location on your server.                                               #
# You must also modify the following variables to match your preferences.    #
##############################################################################

# The absolute or relative path to the directory where all comments will be located.
# It is best that this directory is located in the HTML files directory,
# to prevent errors. It must exist, and must be writable. No trailing slash (/).
$CommentsPath = '/home/ziomax/public_html/news/isay';

##############################################################################
# No changes need to be made after these lines                               #
##############################################################################

print "content-type:text/html\n\n";
$Comments = 0;
if ($ENV{QUERY_STRING} =~ /^ID=([a-zA-Z0-9]+)(&js)?$/i) {
	$JS = 1 if $2;
	if (open ISAY,"$CommentsPath/iSay_$1.txt") {
		@Comments = <ISAY>;
		close ISAY;
		for $i (@Comments) {
			next unless length $i > 2;
			$Comments++;
		}
		$Comments-- if $Comments;
	} else {
		$Comments = 0;
	}
} else {
	$Comments = 'ERROR';
}
if ($JS) {
	print qq~document.write('$Comments');~;
} else {
	print $Comments;
}