Gossamer Forum
Home : General : Perl Programming :

Please help me!!!

Quote Reply
Please help me!!!
I have modify some perl file and some problems exist! I am the first time to write perl, so I really don't know what to do...
Can anyone download the code at http://home.fiberia.com/fe034acdff098345bd003ecf09a0b6/searcher/test/topranker.zip , and told me what's the problem??? Thanks lot!
The following is the content in topranker.zip
This is add.cgi -----------------------------

#!/usr/local/bin/perl

require "variables.pl";
&parse_html;
&parse_query;

if($query{'action'} eq "") {
print "Content-type: text/html\n\n";
print <<HTML;
<font face="$AddFontFace">
<center>
<h2>Add Your Site To The $SiteTitle</h2>
HTML

open(DATA, "$CgiDir/addsite.dat");
while (<DATA> ) {
print "$_";
}
close(DATA);

print <<HTML;
<table>
<tr>
<td>
<font face="$AddFontFace" size="-1">
<form action="add.cgi?action=add" method="post">
<b>E-Mail Address:</b><br>
<input type="text" size="20" name="email"><p>
<b>Site Title:</b><br>
<input type="text" size="40" name="title"><p>
<b>Site URL:</b><br>
<input type="text" size="50" name="url" value="http://"><p>
<b>Site Description:</b><br>
<input type="text" size="50" name="descrip"><p>
<b>Desired Username:</b><br>
<input type="text" size="15" maxsize="10" name="id"><p>
<b>Desired Password:</b><br>
<input type="password" size="15" maxsize="8" name="password"><p>
<input type="submit" value="Add User">
</form>
</td>
</tr>
</table>
HTML
}
elsif($query{'action'} eq "add") {
if(-e "$InfoDir/$form{'id'}" &#0124; &#0124; $form{'id'} eq "rerank") {
print "Content-type: text/html\n\n";
print "<center><h2>Sorry, That Username Is Taken</h2>";
print "Use your browsers back button and select another username";
}
else {
&addMember;
if($good_input) {
&printConfirm;
}
}
}

####################################
# Adds a member to the list
#
sub addMember {
$good_input = 1;
if($form{'title'} eq "" &#0124; &#0124;
$form{'url'} eq "http://" &#0124; &#0124;
$form{'descrip'} eq "" &#0124; &#0124;
$form{'email'} eq "" &#0124; &#0124;
$form{'password'} eq "" &#0124; &#0124;
$form{'id'} eq "") {

$good_input = 0;

print "Content-type: text/html\n\n";
print "<b>You forgot to fill in one or more fields.<br>Press your browsers back button";
print " and fill in these required fields:</b>";
print "<ul>";

if($form{'url'} eq "http://") {
print "<li>Web Site URL";
}

if($form{'descrip'} eq "") {
print "<li>Site Description";
}

if($form{'email'} eq "") {
print "<li>E-Mail Address";
}

if($form{'title'} eq "") {
print "<li>Site Title";
}

if($form{'id'} eq "") {
print "<li>Username";
}

if($form{'password'} eq "") {
print "<li>Password";
}

print "</ul>";
}
}

##################################
# Prints the page to confirm the
# site has been added to the list
#
sub printConfirm {
open(INFO, ">$InfoDir/$form{'id'}");
print INFO "0|$form{'title'}|$form{'url'}|$form{'descrip'}|$form{'email'}|$form{'banner'}|$form{'password'}|";
close(INFO);

chmod(0666, "$InfoDir/$form{'id'}");

open(IN, ">$InDir/$form{'id'}");
print IN "0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|";
close(IN);

chmod(0666, "$InDir/$form{'id'}");

open(OUT, ">$OutDir/$form{'id'}");
print OUT "0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|";
close(OUT);

chmod(0666, "$OutDir/$form{'id'}");

print "Content-type: text/html\n\n";
print <<HTML;
<center>
<font face="$AddFontFace" size="-1">
<h2>Addition Successful</h2>
Your information has been recorded and you<br>
may now begin sending hits to our top list.

<p>

Here's the information you submitted:

<p>

<table border="$AddTableBorder" cellspacing="$AddCellspacing" cellpadding="$AddCellpadding" width="$AddTableWidth" bgcolor="$AddBgColour">
<tr>
<td bgcolor="$AddTitleBgColour">
<font face="$AddFontFace" size=-2>
<b>USERNAME</b>
</td>
<td>
<font face="$AddFontFace" size=-2>
$form{'id'}
</td>
</tr>
<tr>
<td bgcolor="$AddTitleBgColour">
<font face="$AddFontFace" size=-2>
<b>PASSWORD</b>
</td>
<td>
<font face="$AddFontFace" size=-2>
$form{'password'}
</td>
</tr>
<tr>
<td bgcolor="$AddTitleBgColour">
<font face="$AddFontFace" size=-2>
<b>SITE TITLE</b>
</td>
<td>
<font face="$AddFontFace" size=-2>
$form{'title'}
</td>
</tr>
<tr>
<td bgcolor="$AddTitleBgColour">
<font face="$AddFontFace" size=-2>
<b>SITE URL</b>
</td>
<td>
<font face="$AddFontFace" size=-2>
<a href="$form{'url'}">$form{'url'}</a>
</td>
</tr>
<tr>
<td bgcolor="$AddTitleBgColour">
<font face="$AddFontFace" size=-2>
<b>E-MAIL ADDRESS</b>
</td>
<td>
<font face="$AddFontFace" size=-2>
<a href="mailto:$form{'email'}">$form{'email'}</a>
</td>
</tr>
<tr>
<td bgcolor="$AddTitleBgColour">
<font face="$AddFontFace" size=-2>
<b>DESCRIPTION</b>
</td>
<td>
<font face="$AddFontFace" size=-2>
$form{'descrip'}
</td>
</tr>
</table>

<p>

<h3>Linking Information</h3>

Now just place a link on your site that points to:<br>
<font color="red">$CgiUrl/in.cgi?$form{'id'}</font>

<p>

Follow the link below to get acceptable banners<br>
and text to use for your links.

<p>

<a href="$BannerUrl">Banners And Text Links</a>

HTML

open (MAIL,"|$MailCmd -t");
print MAIL "To: $form{'email'}\nFrom: $YourEmail\n";
print MAIL "Subject: Welcome To The $SiteTitle\n\n";
print MAIL "Welcome to the $SiteTitle Top List.\n";
print MAIL "You can begin sending hits to the list at any time\n";
print MAIL "and you will be listed, if you send enough hits, at the\n";
print MAIL "next update. Below is your linking information.\n\n";
print MAIL "URL to send hits to:\n";
print MAIL "$CgiUrl/in.cgi?$form{'id'}\n\n";
print MAIL "URL to get banners and text links:\n";
print MAIL "$BannerUrl\n\n";
print MAIL "Thanks for joining,\nWEBMASTER, $SiteTitle\n";
print MAIL "$HtmlUrl/index.html";
close (MAIL);
}

This is in.cgi ------------------------------

#!/usr/local/bin/perl

require "variables.pl";
&CheckTime;

if($ENV{'QUERY_STRING'} eq "rerank") {
&SortData;
&PrintList;
print "Location: $HtmlUrl/index.html\n\n";
}

if(-e "$InDir/$ENV{'QUERY_STRING'}") {
open(IN, "$ENV{'QUERY_STRING'}");
$IN = <IN>;
close(IN);

($In, $D0In, $D1In, $D2In, $D3In, $D4In, $D5In, $D6In, $D7In, $H0In, $H1In, $H2In, $H3In, $H4In, $H5In, $H6In, $H7In, $H8In, $H9In, $H10In, $H11In, $H12In, $H13In, $H14In, $H15In, $H16In, $H17In, $H18In, $H19In, $H20In, $H21In, $H22In, $H23In, $H24In, $TotalIn) = split(/\|/, $IN);

$In++;
$D0In++;
$H0In++;
$TotalIn++;

open(IN, ">$InDir/$ENV{'QUERY_STRING'}");
flock(IN, 2);
print IN "$In|$D0In|$D1In|$D2In|$D3In|$D4In|$D5In|$D6In|$D7In|$H0In|$H1In|$H2In|$H3In|$H4In|$H5In|$H6In|$H7In|$H8In|$H9In|$H10In|$H11In|$H12In|$H13In |$H14In|$H15In|$H16In|$H17In|$H18In|$H19In|$H20In|$H21In|$H22In|$H23In|$H24In|$TotalIn|";
close(IN);

print "Location: $HtmlUrl/index.html\n\n";
}
else {
print "Location: $HtmlUrl/index.html\n\n";
}

This is out.cgi -----------------------------

#!/usr/local/bin/perl

require "variables.pl";
&CheckTime;

if(-e "$OutDir/$ENV{'QUERY_STRING'}") {
open(OUT, "$OutDir/$ENV{'QUERY_STRING'}");
$OUT = <OUT>;
close(OUT);

($Out, $D0Out, $D1Out, $D2Out, $D3Out, $D4Out, $D5Out, $D6Out, $D7Out, $H0Out, $H1Out, $H2Out, $H3Out, $H4Out, $H5Out, $H6Out, $H7Out, $H8Out, $H9Out, $H10Out, $H11Out, $H12Out, $H13Out, $H14Out, $H15Out, $H16Out, $H17Out, $H18Out, $H19Out, $H20Out, $H21Out, $H22Out, $H23Out, $H24Out, $TotalOut) = split(/\|/, $OUT);

$Out++;
$D0Out++;
$H0Out++;
$TotalOut++;

open(OUT, ">$OutDir/$ENV{'QUERY_STRING'}");
flock(OUT, 2);
print OUT "$Out|$D0Out|$D1Out|$D2Out|$D3Out|$D4Out|$D5Out|$D6Out|$D7Out|$H0Out|$H1Out|$H2Out|$H3Out|$H4Out|$H5Out|$H6Out|$H7Out|$H8Out|$H9Out|$H10Out| $H11Out|$H12Out|$H13Out|$H14Out|$H15Out|$H16Out|$H17Out|$H18Out|$H19Out|$H20Out|$H21Out|$H22Out|$H23Out|$H24Out|$TotalOut|";
close(OUT);

open(INFO, "$InfoDir/$ENV{'QUERY_STRING'}");
$INFO = <INFO>;
close(INFO);

($mark, $url, $title, $descrip, $email, $banner, $password) = split(/\|/, $INFO);

print "Location: $url\n\n";
}
else {
print "Location: $HtmlUrl/wrongid.html\n\n";
}

This is variables.pl ------------------------

$SiteTitle = "Top Ranker 50";
# The title of your site

$CgiDir = "/usr/local/www/users/searcher/test/cgi-bin";
# The full UNIX path to all the
# cgi files are located for this script

$CgiUrl = "http://home.fiberia.com/fe034acdff098345bd003ecf09a0b6/searcher/test/cgi-bin";
# The full URL to the location of all script files

$HtmlDir = "/usr/local/www/users/searcher/test/TopRanker";
# The full UNIX path to where the
# HTML file (the html file containing the list) will be located

$HtmlUrl = "http://home.fiberia.com/fe034acdff098345bd003ecf09a0b6/searcher/test/TopRanker";
# The full URL to the location of where the html file
# (the html file containing the list) will be located

$InfoDir = "/usr/local/www/users/searcher/test/info";
# Full UNIX path to location
# where members info files are placed
#
# This must be an empty directory!

$InDir = "/usr/local/www/users/searcher/test/in";
# Full UNIX path to location
# where members incoming statistic files are placed
#
# This must be an empty directory!

$OutDir = "/usr/local/www/users/searcher/test/out";
# Full UNIX path to location
# where members outcoming statistic files are placed
#
# This must be an empty directory!

$BannerUrl = "/usr/local/www/users/searcher/test/banners.html";
# Full URL to a page that contains banners and
# proper text links for your members to use.
# Members will be given a link to this page after
# they add their site.

$DateCmd = '/bin/date';
# UNIX date command. Can be found with the following command at a UNIX prompt:
# which date
# If this does not help you contact your system administrator

$MailCmd = '/usr/sbin/sendmail';
# UNIX Sendmail command
#
# This has to point to your sendmail program. If your server does not
# have sendmail, you may need to modify the open(MAIL,"|$MailCmd -t");
# lines in all of the scripts to support whatever format your server
# e-mail system requires. If you are not sure, ask your server
# administrator.
#
# To help in locating this try the following command at a UNIX prompt:
# which sendmail
# If this does not help you contact your system administrator

$YourEmail = "mp3searcher\@softhome.net";
# Your e-mail address.
# NOTE: The backslash before the @ IS required.

$ListSize = "50";
# The total number of sites to list.

$RerankTime = "900";

$ResetTime = "86400";

#################################################################################
# VARIABLES FOR THE LOOK OF THE RANKING PAGE #
#################################################################################

$RankTableBorder = "1";
# The size of the border around the ranking list.

$RankTableWidth = "80%";
# The width you want the table to be, can eitherbe a percent or a number.

$RankCellpadding = "10";
# cellpadding value for the ranking list table.

$RankCellspacing = "0";
# cellspacing value for the ranking list table.

$RankFontFace = "Arial";
# The font to be used throughout the ranking list.

$RankBgColour = "#ffffff";
# The background color of the rows containing the ranking list.

$RankTitleBgColour = "#DCDCDC";
# The background color of the row containing titles for the list.
# RANK, TITLE, MARK.

#################################################################################
# VARIABLES FOR THE LOOK OF add.cgi #
#################################################################################

$AddTableBorder = "1";
# The size of the border around the conformation list.

$AddTableWidth = "80%";
# The width you want the table to be, can either be a percent or a number.

$AddCellpadding = "10";
# cellpadding value for the conformation list table.

$AddCellspacing = "0";
# cellspacing value for the conformation list table.

$AddFontFace = "Arial";
# The font to be used throughout the conformation list.

$AddBgColour = "#ffffff";
# The background color of the columns containing the user information.

$AddTitleBgColour = "#DCDCDC";
# The background color of the Columns containing titles for the user information.
# USERNAME, PASSWORD, SITE TITLE, SITE URL, E-MAIL ADDRESS, DESCRIPTION.

########### DONE - NO MORE EDITING NEEDS TO BE DONE TO THIS FILE ##############

$curTime = `$DateCmd +"%B %d, %Y %T %Z"`;
$header_file = "header.txt";
$footer_file = "footer.txt";

###############################################
# Parse information submitted through web form
# **Removes any html from the information
#
sub parse_html {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/~!/ ~!/g;
$value =~ s/<([^>]|\n)*>//g;
$form{$name} = $value;
}
}

#####################
# Parse query string
#
sub parse_query {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$query{$name} = $value;
}
}

#########################################
# Gathers data from info files and sorts
#
sub SortData {
opendir (INFO, "$InfoDir");
@filenames = grep (!/^\.\.?$/, readdir (INFO));
closedir (INFO);
$num_of_files = @filenames;

foreach $i (@filenames) {
open (INFO, "$InfoDir/$i");
$INFO = <INFO>;
close (INFO);
$data_array{$i} = $INFO;
}

@sorted_data = sort {$data_array{$b} <=> $data_array{$a}} keys(%data_array);
}

###############################
# Check to see if it is time
# to update/reset list
#
sub CheckTime {
open(TIME, "$CgiDirtime");
$TIME=<TIME>;
close (TIME);
($Time1, $Time2, $Time3, $Time4) = split(/\|/, $TIME);
$TimeNow = time;

if (int($TimeNow/$RerankTime) != int($Time1/$RerankTime)) {
open(TIME, "$CgiDir/time");
flock(TIME, 2);
print TIME "$TimeNow|$Time2|$Time3|$Time4|";
close (TIME);
&SortData;
&PrintList;
}

if (int($TimeNow/$ResetTime) != int($Time2/$ResetTime)) {
open(TIME, "$CgiDir/time");
flock(TIME, 2);
print TIME "$Time1|$TimeNow|$Time3|$Time4|";
close (TIME);
&Reset;
}

if (int($TimeNow/(60*60)) != int($Time3/(60*60)) {
open(TIME, "$CgiDir/time");
flock(TIME, 2);
print TIME "$Time1|$Time2|$TimeNow|$Time4|";
close (TIME);
&UpdateHourlyStat;
}

if (int($TimeNow/(60*60*24)) != int($Time4/(60*60*24)) {
open(TIME, "$CgiDir/time");
flock(TIME, 2);
print TIME "$Time1|$Time2|$Time3|$TimeNow|";
close (TIME);
&UpdateDailyStat;
}
}

#################################################################################
# Reset all counters #
#################################################################################

sub Reset {
opendir (IN, "$InDir");
@filenames = grep (!/^\.\.?$/, readdir (IN));
closedir (IN);

foreach $i (@filenames) {
open(IN, "$InDir/$i");
$IN = <IN>;
close(IN);

($In, $D0In, $D1In, $D2In, $D3In, $D4In, $D5In, $D6In, $D7In, $H0In, $H1In, $H2In, $H3In, $H4In, $H5In, $H6In, $H7In, $H8In, $H9In, $H10In, $H11In, $H12In, $H13In, $H14In, $H15In, $H16In, $H17In, $H18In, $H19In, $H20In, $H21In, $H22In, $H23In, $H24In, $TotalIn) = split(/\|/, $IN);

open(IN, ">$InDir/$i");
flock(IN, 2);
print IN "$In|$D0In|$D1In|$D2In|$D3In|$D4In|$D5In|$D6In|$D7In|$H0In|$H1In|$H2In|$H3In|$H4In|$H5In|$H6In|$H7In|$H8In|$H9In|$H10In|$H11In|$H12In|$H13In |$H14In|$H15In|$H16In|$H17In|$H18In|$H19In|$H20In|$H21In|$H22In|$H23In|$H24In|$TotalIn|";
close(IN);
}

opendir (OUT, "$OutDir");
@filenames = grep (!/^\.\.?$/, readdir (OUT));
closedir (OUT);

foreach $i (@filenames) {
open(OUT, "$OutDir/$i");
$OUT = <OUT>;
close(OUT);

($Out, $D0Out, $D1Out, $D2Out, $D3Out, $D4Out, $D5Out, $D6Out, $D7Out, $H0Out, $H1Out, $H2Out, $H3Out, $H4Out, $H5Out, $H6Out, $H7Out, $H8Out, $H9Out, $H10Out, $H11Out, $H12Out, $H13Out, $H14Out, $H15Out, $H16Out, $H17Out, $H18Out, $H19Out, $H20Out, $H21Out, $H22Out, $H23Out, $H24Out, $TotalOut) = split(/\|/, $OUT);

open(OUT, ">$OutDir/$i");
flock(OUT, 2);
print OUT "$Out|$D0Out|$D1Out|$D2Out|$D3Out|$D4Out|$D5Out|$D6Out|$D7Out|$H0Out|$H1Out|$H2Out|$H3Out|$H4Out|$H5Out|$H6Out|$H7Out|$H8Out|$H9Out|$H10Out| $H11Out|$H12Out|$H13Out|$H14Out|$H15Out|$H16Out|$H17Out|$H18Out|$H19Out|$H20Out|$H21Out|$H22Out|$H23Out|$H24Out|$TotalOut|";
close(OUT);
}

opendir (INFO, "$InfoDir");
@filenames = grep (!/^\.\.?$/, readdir (INFO));
closedir (INFO);

foreach $i (@filenames) {
open(INFO, "$InfoDir/$i");
$INFO = <INFO>;
close(INFO);

($mark, $url, $title, $descrip, $email, $banner, $password) = split(/\|/, $INFO);

$UpMark = int (((($In * 2) + $Out) / 3) + 0.5)

open(INFO, ">$InfoDir/$i");
flock(INFO, 2);
print INFO "$UpMark|$title|$url|$descrip|$email|$banner|$password|";
close(INFO);
}
}

#################################################################################
# Resets all hourly stats #
#################################################################################

sub UpdateHourlyStat {
opendir (IN, "$InDir");
@filenames = grep (!/^\.\.?$/, readdir (IN));
closedir (IN);

foreach $i (@filenames) {
open(IN, "$InDir/$i");
$IN = <IN>;
close(IN);

($In, $D0In, $D1In, $D2In, $D3In, $D4In, $D5In, $D6In, $D7In, $H0In, $H1In, $H2In, $H3In, $H4In, $H5In, $H6In, $H7In, $H8In, $H9In, $H10In, $H11In, $H12In, $H13In, $H14In, $H15In, $H16In, $H17In, $H18In, $H19In, $H20In, $H21In, $H22In, $H23In, $H24In, $TotalIn) = split(/\|/, $IN);

$UpH0In = 0;
$UpH1In = $H0In;
$UpH2In = $H1In;
$UpH3In = $H2In;
$UpH4In = $H3In;
$UpH5In = $H4In;
$UpH7In = $H6In;
$UpH8In = $H7In;
$UpH9In = $H8In;
$UpH10In = $H9In;
$UpH11In = $H10In;
$UpH12In = $H11In;
$UpH13In = $H12In;
$UpH14In = $H13In;
$UpH15In = $H14In;
$UpH16In = $H15In;
$UpH17In = $H16In;
$UpH18In = $H17In;
$UpH19In = $H18In;
$UpH20In = $H19In;
$UpH21In = $H20In;
$UpH22In = $H21In;
$UpH23In = $H22In;
$UpH24In = $H23In;

open(IN, ">$InDir/$i");
flock(IN, 2);
print IN "$In|$D0In|$D1In|$D2In|$D3In|$D4In|$D5In|$D6In|$D7In|$UpH0In|$UpH1In|$UpH2In|$UpH3In|$UpH4In|$UpH5In|$UpH6In|$UpH7In|$UpH8In|$UpH9In|$UpH10I n|$UpH11In|UpH12In|$UpH13In|$UpH14In|$UpH15In|$UpH16In|$UpH17In|$UpH18In|$UpH19In|$UpH20In|$UpH21In|$UpH22In|$UpH23In|$UpH24In|$TotalIn|";
close(IN);
}

opendir (OUT, "$OutDir");
@filenames = grep (!/^\.\.?$/, readdir (OUT));
closedir (OUT);

foreach $i (@filenames) {
open(OUT, "$OutDir/$i");
$OUT = <OUT>;
close(OUT);

($Out, $D0Out, $D1Out, $D2Out, $D3Out, $D4Out, $D5Out, $D6Out, $D7Out, $H0Out, $H1Out, $H2Out, $H3Out, $H4Out, $H5Out, $H6Out, $H7Out, $H8Out, $H9Out, $H10Out, $H11Out, $H12Out, $H13Out, $H14Out, $H15Out, $H16Out, $H17Out, $H18Out, $H19Out, $H20Out, $H21Out, $H22Out, $H23Out, $H24Out, $TotalOut) = split(/\|/, $OUT);

$UpH0Out = 0;
$UpH1Out = $H0Out;
$UpH2Out = $H1Out;
$UpH3Out = $H2Out;
$UpH4Out = $H3Out;
$UpH5Out = $H4Out;
$UpH7Out = $H6Out;
$UpH8Out = $H7Out;
$UpH9Out = $H8Out;
$UpH10Out = $H9Out;
$UpH11Out = $H10Out;
$UpH12Out = $H11Out;
$UpH13Out = $H12Out;
$UpH14Out = $H13Out;
$UpH15Out = $H14Out;
$UpH16Out = $H15Out;
$UpH17Out = $H16Out;
$UpH18Out = $H17Out;
$UpH19Out = $H18Out;
$UpH20Out = $H19Out;
$UpH21Out = $H20Out;
$UpH22Out = $H21Out;
$UpH23Out = $H22Out;
$UpH24Out = $H23Out;

open(OUT, ">$OutDir/$i");
flock(OUT, 2);
print OUT "$Out|$D0Out|$D1Out|$D2Out|$D3Out|$D4Out|$D5Out|$D6Out|$D7Out|$UpH0Out|$UpH1Out|$UpH2Out|$UpH3Out|$UpH4Out|$UpH5Out|$UpH6Out|$UpH7Out|$UpH8O ut|$UpH9Out|$UpH10Out|$UpH11Out|UpH12Out|$UpH13Out|$UpH14Out|$UpH15Out|$UpH16Out|$UpH17Out|$UpH18Out|$UpH19Out|$UpH20Out|$UpH21Out|$UpH22Out |$UpH23Out|$UpH24Out|$TotalOut|";
close(OUT);
}
}

#################################################################################
# Resets all daily stats #
#################################################################################
sub UpdateDailyStat {
opendir (IN, "$InDir");
@filenames = grep (!/^\.\.?$/, readdir (IN));
closedir (IN);

foreach $i (@filenames) {
open(IN, "$InDir/$i");
$IN = <IN>;
close(IN);

($In, $D0In, $D1In, $D2In, $D3In, $D4In, $D5In, $D6In, $D7In, $H0In, $H1In, $H2In, $H3In, $H4In, $H5In, $H6In, $H7In, $H8In, $H9In, $H10In, $H11In, $H12In, $H13In, $H14In, $H15In, $H16In, $H17In, $H18In, $H19In, $H20In, $H21In, $H22In, $H23In, $H24In, $TotalIn) = split(/\|/, $IN);

$UpD0In = 0;
$UpD1In = $D0In;
$UpD2In = $D1In;
$UpD3In = $D2In;
$UpD4In = $D3In;
$UpD5In = $D4In;
$UpD6In = $D5In;
$UpD7In = $D6In;

open(IN, ">$InDir/$i");
flock(IN, 2);
print IN "$In|$UpD0In|$UpD1In|$UpD2In|$UpD3In|$UpD4In|$UpD5In|$UpD6In|$UpD7In|$H0In|$H1In|$H2In|$H3In|$H4In|$H5In|$H6In|$H7In|$H8In|$H9In|$H10In|$H11 In|$H12In|$H13In|$H14In|$H15In|$H16In|$H17In|$H18In|$H19In|$H20In|$H21In|$H22In|$H23In|$H24In|$TotalIn|";
close(IN);
}

opendir (OUT, "$OutDir");
@filenames = grep (!/^\.\.?$/, readdir (OUT));
closedir (OUT);

foreach $i (@filenames) {
open(OUT, "$OutDir/$i");
$OUT = <OUT>;
close(OUT);

($Out, $D0Out, $D1Out, $D2Out, $D3Out, $D4Out, $D5Out, $D6Out, $D7Out, $H0Out, $H1Out, $H2Out, $H3Out, $H4Out, $H5Out, $H6Out, $H7Out, $H8Out, $H9Out, $H10Out, $H11Out, $H12Out, $H13Out, $H14Out, $H15Out, $H16Out, $H17Out, $H18Out, $H19Out, $H20Out, $H21Out, $H22Out, $H23Out, $H24Out, $TotalOut) = split(/\|/, $OUT);

$UpD0Out = 0;
$UpD1Out = $D0Out;
$UpD2Out = $D1Out;
$UpD3Out = $D2Out;
$UpD4Out = $D3Out;
$UpD5Out = $D4Out;
$UpD6Out = $D5Out;
$UpD7Out = $D6Out;

open(OUT, ">$OutDir/$i");
flock(OUT, 2);
print OUT "$Out|$UpD0Out|$UpD1Out|$UpD2Out|$UpD3Out|$UpD4Out|$UpD5Out|$UpD6Out|$UpD7Out|$H0Out|$H1Out|$H2Out|$H3Out|$H4Out|$H5Out|$H6Out|$H7Out|$H8Out |$H9Out|$H10Out|$H11Out|$H12Out|$H13Out|$H14Out|$H15Out|$H16Out|$H17Out|$H18Out|$H19Out|$H20Out|$H21Out|$H22Out|$H23Out|$H24Out|$TotalOut|";
close(OUT);
}
}

###############################
# Print the list to rankem.html
#
sub PrintList {
$rank = 1;
$stop = 0;

open(HTMLFILE, ">$HtmlDir/index.html");
flock(HTMLFILE, 2);

open(HEADER, "$CgiDir/$header_file");
while(<HEADER> ) {
print HTMLFILE "$_";
}
close(HEADER);

print HTMLFILE qq|<table border="$RankTableBorder" cellspacing="$RankCellspacing" cellpadding="$RankCellpadding" width="$RankTableWidth">|;

print HTMLFILE qq|<tr bgcolor="$RankTitleBgColour">
<td align="center" width="5%">
<font face="$RankFontFace" size="-1"><b>NO.
</td>
<td align="center" width="85%">
<font face="$RankFontFace" size="-1"><b>SITE
</td>
<td align="center" width="10%">
<font face="$RankFontFace" size="-1"><b>MARK
</td>|;
print HTMLFILE "</tr>";

for ($s; $s <= $ListSize; $s++) {
if ($stop < $num_of_files) {
$stop++;
$user = $sorted_data[$s];

open (TEMP, "$InfoDir/$user");
$line = <TEMP>;
close (TEMP);

($mark, $title, $url, $descrip, $email, $banner, $password) = split (/\|/, $line);

if (($rank <= $ListSize) && ($data_array{$user} >= 1)) {
print HTMLFILE qq|<tr bgcolor="$list_bgcolor"><td align="center" width="5%"><font face="$RankFontFace" size="-1">$rank</td><td align="center" width="85%"><font face="$RankFontFace" size="-1">|;

print HTMLFILE qq|<a href="$CgiUrl/out.cgi?$user">|;

print HTMLFILE qq|$title</a><br>$descrip</td>
<td align="center" width="10%">
<font face="$RankFontFace" size="-1">$mark
</td>|;


print HTMLFILE qq|</tr>|;
}
}
$rank++;
}
print HTMLFILE qq|</table><p><font face="$RankFontFace" font size="-2">Last Updated: $curTime</font><p>|;


open(FOOTER, "$CgiDir/$footer_file");
while(<FOOTER> ) {
print HTMLFILE "$_";
}
close(FOOTER);
close(HTMLFILE);
}

That's all ----------------------------------

I will really very very happy if anyone can help me...
THANKS!!!
Quote Reply
Re: Please help me!!! In reply to
PS. This perl code upside is used to Rank Top Sites.
Quote Reply
Re: Please help me!!! In reply to
Pop,

I like that you included all this code for us to look at, but its really hard for someone to debug raw code without knowing a few things about the problems you are having. First off.. what kind of errors are you getting? Have you checked error logs on your server for specific problems generated by your code? Are you able to run your code from a prompt.

Most likely, the problem stems from one of two sources:

1) The variables.pl is misconfigured or you have unknowingly inserted an error into that code.
2) Changes you made to the add.cgi had a Perl error in them.

I can't diagnose the problem without the variables.pl file. If you want to ZIP the files you use and send them to me, I will try to troubleshoot your code.


------------------
Fred Hirsch
Web Consultant & Programmer
Quote Reply
Re: Please help me!!! In reply to
I don't know about you, but this code scares the bejeebers out of me. Smile

Things like:

Quote:
if(-e "$InDir/$ENV{'QUERY_STRING'}") {
open(IN, "$ENV{'QUERY_STRING'}");

or worse:

Quote:
open(INFO, ">$InfoDir/$form{'id'}");

I would not recommend putting this code on anyone's server. It would be very easy to cause damage, or crash the script (that's my impression from a 5 minute glance).

A good way to check if your program follows good programming practices is to check if open() calls and other system calls are checked for errors. Novice programmers will often do:

open (IN, "blah.txt");

and not check to see if the open was successful. This will cause the script to continue running when it should have coughed up an error, leading to possible disasertous results..

Just my 0.02..

Alex
Quote Reply
Re: Please help me!!! In reply to
I get SERVER ERROR on all *.cgi .
I modified it from rankem' lite which you can get it at http://www.cgi-works.net/cgi-bn/download.cgi?v=f&script=rankemlite
Thanks for your help!!!
Quote Reply
Re: Please help me!!! In reply to
I have make some modification to in.cgi . I guess I have make it possible to run by itself, the other files are not require. But I Still get SERVER ERROR.

Here is the error message.
---------------------------------------------
Server Error


File executable permissions:
the permissions are OK

Perl Diagnostics:
syntax error at /usr/local/www/users/searcher/test/cgi-bin/in.cgi line 71, near "print" syntax error at /usr/local/www/users/searcher/test/cgi-bin/in.cgi line 81, near "print" syntax error at /usr/local/www/users/searcher/test/cgi-bin/in.cgi line 84, near "}" /usr/local/www/users/searcher/test/cgi-bin/in.cgi had compilation errors.

Other Suggestions:
If you were trying to execute a perl script CGI: make sure that the file extension is .cgi, that you uploaded with FTP in ASCII mode and that the script starts with #!/usr/local/bin/perl
Also, verify if your script is Perl 5 compatible.
---------------------------------------------

Here Is the file in.cgi .
---------------------------------------------
#!/usr/local/bin/perl

$HtmlUrl = "http://home.fiberia.com/fe034acdff098345bd003ecf09a0b6/searcher/test/TopRanker";
$CgiDir = "/usr/local/www/users/searcher/test/cgi-bin";
$InDir = "/usr/local/www/users/searcher/test/in";
$OutDir = "/usr/local/www/users/searcher/test/out";
$InfoDir = "/usr/local/www/users/searcher/test/info";
$RerankTime = "900";
$ResetTime = "86400";
&CheckTime;

if($ENV{'QUERY_STRING'} eq "rerank") {
&PrintList;
print "Location: $HtmlUrl/index.html\n\n";
}

if(-e "$InDir/$ENV{'QUERY_STRING'}") {
open(IN, "$InDir/$ENV{'QUERY_STRING'}") &#0124; &#0124; &problem("Could Not Open $InDir/$ENV{'QUERY_STRING'}");
$IN = <IN>;
close(IN);

($In, $D0In, $D1In, $D2In, $D3In, $D4In, $D5In, $D6In, $D7In, $H0In, $H1In, $H2In, $H3In, $H4In, $H5In, $H6In, $H7In, $H8In, $H9In, $H10In, $H11In, $H12In, $H13In, $H14In, $H15In, $H16In, $H17In, $H18In, $H19In, $H20In, $H21In, $H22In, $H23In, $H24In, $TotalIn) = split(/\|/, $IN);

$In++;
$D0In++;
$H0In++;
$TotalIn++;

open(IN, ">$InDir/$ENV{'QUERY_STRING'}") &#0124; &#0124; &problem("Could Not Write $InDir/$ENV{'QUERY_STRING'}");
flock(IN, 2);
print IN "$In|$D0In|$D1In|$D2In|$D3In|$D4In|$D5In|$D6In|$D7In|$H0In|$H1In|$H2In|$H3In|$H4In|$H5In|$H6In|$H7In|$H8In|$H9In|$H10In|$H11In|$H12In|$H13In |$H14In|$H15In|$H16In|$H17In|$H18In|$H19In|$H20In|$H21In|$H22In|$H23In|$H24In|$TotalIn|";
close(IN);

print "Location: $HtmlUrl/index.html\n\n";
}
else {
print "Location: $HtmlUrl/index.html\n\n";
}

###############################
# Check to see if it is time
# to update/reset list
#
sub CheckTime {

open(TIME1, "$CgiDir/time1.txt") &#0124; &#0124; &problem("Could Not Open $CgiDir/time1.txt");
$Time1 = <TIME1>;
close (TIME1);
if (int(time()/$RerankTime) != int($Time1/$RerankTime)) {
open(TIME1, "$>CgiDir/time1.txt") &#0124; &#0124; &problem("Could Not Write $CgiDir/time1.txt");
print TIME1 time() &#0124; &#0124; &problem("Could Not Print $CgiDir/time1.txt");
close (TIME1);
&PrintList;
}

open(TIME2, "$CgiDir/time2.txt") &#0124; &#0124; &problem("Could Not Open $CgiDir/time2.txt");
$Time2 = <TIME2>;
close (TIME2);
if (int(time()/$ResetTime) != int($Time2/$ResetTime)) {
open(TIME2, ">$CgiDir/time2.txt") &#0124; &#0124; &problem("Could Not Write $CgiDir/time2.txt");
print TIME2 time() &#0124; &#0124; &problem("Could Not Print $CgiDir/time2.txt");
close (TIME2);
&Reset;
}

open(TIME3, "$CgiDir/time3.txt") &#0124; &#0124; &problem("Could Not Open $CgiDir/time3.txt");
$Time3 = <TIME3>;
close (TIME3);
if (int(time()/(60*60)) != int($Time3/(60*60)) {
open(TIME3, ">$CgiDir/time3.txt") &#0124; &#0124; &problem("Could Not Write $CgiDir/time3.txt");
print TIME3 time() &#0124; &#0124; &problem("Could Not Print $CgiDir/time3.txt");
close (TIME3);
&UpdateHourlyStat;
}

open(TIME4, "$CgiDir/time4.txt") &#0124; &#0124; &problem("Could Not Open $CgiDir/time4.txt");
$Time4 = <TIME4>;
close (TIME4);
if (int(time()/(60*60*24)) != int($Time4/(60*60*24)) {
open(TIME4, ">$CgiDir/time4.txt") &#0124; &#0124; &problem("Could Not Write $CgiDir/time4.txt");
print TIME4 time() &#0124; &#0124; &problem("Could Not Print $CgiDir/time3.txt");
close (TIME4);
&UpdateDailyStat;
}
}

#################################################################################
# Reset all counters #
#################################################################################

sub Reset {
opendir (IN, "$InDir") &#0124; &#0124; &problem("Could Not Open $InDir");
@filenames = grep (!/^\.\.?$/, readdir (IN));
closedir (IN);

foreach $i (@filenames) {
open(IN, "$InDir/$i") &#0124; &#0124; &problem("Could Not Open $InDir/$i");
$IN = <IN>;
close(IN);

($In, $D0In, $D1In, $D2In, $D3In, $D4In, $D5In, $D6In, $D7In, $H0In, $H1In, $H2In, $H3In, $H4In, $H5In, $H6In, $H7In, $H8In, $H9In, $H10In, $H11In, $H12In, $H13In, $H14In, $H15In, $H16In, $H17In, $H18In, $H19In, $H20In, $H21In, $H22In, $H23In, $H24In, $TotalIn) = split(/\|/, $IN);

open(IN, ">$InDir/$i") &#0124; &#0124; &problem("Could Not Print $InDir/$i");
flock(IN, 2);
print IN "$In|$D0In|$D1In|$D2In|$D3In|$D4In|$D5In|$D6In|$D7In|$H0In|$H1In|$H2In|$H3In|$H4In|$H5In|$H6In|$H7In|$H8In|$H9In|$H10In|$H11In|$H12In|$H13In |$H14In|$H15In|$H16In|$H17In|$H18In|$H19In|$H20In|$H21In|$H22In|$H23In|$H24In|$TotalIn|";
close(IN);
}

opendir (OUT, "$OutDir") &#0124; &#0124; &problem("Could Not Open $OutDir");
@filenames = grep (!/^\.\.?$/, readdir (OUT));
closedir (OUT);

foreach $i (@filenames) {
open(OUT, "$OutDir/$i") &#0124; &#0124; &problem("Could Not Open $OutDir/$i");
$OUT = <OUT>;
close(OUT);

($Out, $D0Out, $D1Out, $D2Out, $D3Out, $D4Out, $D5Out, $D6Out, $D7Out, $H0Out, $H1Out, $H2Out, $H3Out, $H4Out, $H5Out, $H6Out, $H7Out, $H8Out, $H9Out, $H10Out, $H11Out, $H12Out, $H13Out, $H14Out, $H15Out, $H16Out, $H17Out, $H18Out, $H19Out, $H20Out, $H21Out, $H22Out, $H23Out, $H24Out, $TotalOut) = split(/\|/, $OUT);

open(OUT, ">$OutDir/$i") &#0124; &#0124; &problem("Could Not Print $OutDir/$i");
flock(OUT, 2);
print OUT "$Out|$D0Out|$D1Out|$D2Out|$D3Out|$D4Out|$D5Out|$D6Out|$D7Out|$H0Out|$H1Out|$H2Out|$H3Out|$H4Out|$H5Out|$H6Out|$H7Out|$H8Out|$H9Out|$H10Out| $H11Out|$H12Out|$H13Out|$H14Out|$H15Out|$H16Out|$H17Out|$H18Out|$H19Out|$H20Out|$H21Out|$H22Out|$H23Out|$H24Out|$TotalOut|";
close(OUT);
}

opendir (INFO, "$InfoDir") &#0124; &#0124; &problem("Could Not Open $InfoDir");
@filenames = grep (!/^\.\.?$/, readdir (INFO));
closedir (INFO);

foreach $i (@filenames) {
open(INFO, "$InfoDir/$i") &#0124; &#0124; &problem("Could Not Open $InfoDir/$i");
$INFO = <INFO>;
close(INFO);

($mark, $url, $title, $descrip, $email, $banner, $password) = split(/\|/, $INFO);

$UpMark = int (((($In * 2) + $Out) / 3) + 0.5)

open(INFO, ">$InfoDir/$i") &#0124; &#0124; &problem("Could Not Print $InfoDir/$i");
flock(INFO, 2);
print INFO "$UpMark|$title|$url|$descrip|$email|$banner|$password|";
close(INFO);
}
}

#################################################################################
# Resets all hourly stats #
#################################################################################

sub UpdateHourlyStat {
opendir (IN, "$InDir") &#0124; &#0124; &problem("Could Not Open $InDir");
@filenames = grep (!/^\.\.?$/, readdir (IN));
closedir (IN);

foreach $i (@filenames) {
open(IN, "$InDir/$i") &#0124; &#0124; &problem("Could Not Open $InDir/$i");
$IN = <IN>;
close(IN);

($In, $D0In, $D1In, $D2In, $D3In, $D4In, $D5In, $D6In, $D7In, $H0In, $H1In, $H2In, $H3In, $H4In, $H5In, $H6In, $H7In, $H8In, $H9In, $H10In, $H11In, $H12In, $H13In, $H14In, $H15In, $H16In, $H17In, $H18In, $H19In, $H20In, $H21In, $H22In, $H23In, $H24In, $TotalIn) = split(/\|/, $IN);

$UpH0In = 0;
$UpH1In = $H0In;
$UpH2In = $H1In;
$UpH3In = $H2In;
$UpH4In = $H3In;
$UpH5In = $H4In;
$UpH7In = $H6In;
$UpH8In = $H7In;
$UpH9In = $H8In;
$UpH10In = $H9In;
$UpH11In = $H10In;
$UpH12In = $H11In;
$UpH13In = $H12In;
$UpH14In = $H13In;
$UpH15In = $H14In;
$UpH16In = $H15In;
$UpH17In = $H16In;
$UpH18In = $H17In;
$UpH19In = $H18In;
$UpH20In = $H19In;
$UpH21In = $H20In;
$UpH22In = $H21In;
$UpH23In = $H22In;
$UpH24In = $H23In;

open(IN, ">$InDir/$i") &#0124; &#0124; &problem("Could Not Print $InDir/$i");
flock(IN, 2);
print IN "$In|$D0In|$D1In|$D2In|$D3In|$D4In|$D5In|$D6In|$D7In|$UpH0In|$UpH1In|$UpH2In|$UpH3In|$UpH4In|$UpH5In|$UpH6In|$UpH7In|$UpH8In|$UpH9In|$UpH10I n|$UpH11In|UpH12In|$UpH13In|$UpH14In|$UpH15In|$UpH16In|$UpH17In|$UpH18In|$UpH19In|$UpH20In|$UpH21In|$UpH22In|$UpH23In|$UpH24In|$TotalIn|";
close(IN);
}

opendir (OUT, "$OutDir") &#0124; &#0124; &problem("Could Not Open $OutDir");
@filenames = grep (!/^\.\.?$/, readdir (OUT));
closedir (OUT);

foreach $i (@filenames) {
open(OUT, "$OutDir/$i") &#0124; &#0124; &problem("Could Not Open $OutDir/$i");
$OUT = <OUT>;
close(OUT);

($Out, $D0Out, $D1Out, $D2Out, $D3Out, $D4Out, $D5Out, $D6Out, $D7Out, $H0Out, $H1Out, $H2Out, $H3Out, $H4Out, $H5Out, $H6Out, $H7Out, $H8Out, $H9Out, $H10Out, $H11Out, $H12Out, $H13Out, $H14Out, $H15Out, $H16Out, $H17Out, $H18Out, $H19Out, $H20Out, $H21Out, $H22Out, $H23Out, $H24Out, $TotalOut) = split(/\|/, $OUT);

$UpH0Out = 0;
$UpH1Out = $H0Out;
$UpH2Out = $H1Out;
$UpH3Out = $H2Out;
$UpH4Out = $H3Out;
$UpH5Out = $H4Out;
$UpH7Out = $H6Out;
$UpH8Out = $H7Out;
$UpH9Out = $H8Out;
$UpH10Out = $H9Out;
$UpH11Out = $H10Out;
$UpH12Out = $H11Out;
$UpH13Out = $H12Out;
$UpH14Out = $H13Out;
$UpH15Out = $H14Out;
$UpH16Out = $H15Out;
$UpH17Out = $H16Out;
$UpH18Out = $H17Out;
$UpH19Out = $H18Out;
$UpH20Out = $H19Out;
$UpH21Out = $H20Out;
$UpH22Out = $H21Out;
$UpH23Out = $H22Out;
$UpH24Out = $H23Out;

open(OUT, ">$OutDir/$i") &#0124; &#0124; &problem("Could Not Print $OutDir/$i");
flock(OUT, 2);
print OUT "$Out|$D0Out|$D1Out|$D2Out|$D3Out|$D4Out|$D5Out|$D6Out|$D7Out|$UpH0Out|$UpH1Out|$UpH2Out|$UpH3Out|$UpH4Out|$UpH5Out|$UpH6Out|$UpH7Out|$UpH8O ut|$UpH9Out|$UpH10Out|$UpH11Out|UpH12Out|$UpH13Out|$UpH14Out|$UpH15Out|$UpH16Out|$UpH17Out|$UpH18Out|$UpH19Out|$UpH20Out|$UpH21Out|$UpH22Out |$UpH23Out|$UpH24Out|$TotalOut|";
close(OUT);
}
}

#################################################################################
# Resets all daily stats #
#################################################################################
sub UpdateDailyStat {
opendir (IN, "$InDir") &#0124; &#0124; &problem("Could Not Open $InDir");
@filenames = grep (!/^\.\.?$/, readdir (IN));
closedir (IN);

foreach $i (@filenames) {
open(IN, "$InDir/$i") &#0124; &#0124; &problem("Could Not Open $InDir/$i");
$IN = <IN>;
close(IN);

($In, $D0In, $D1In, $D2In, $D3In, $D4In, $D5In, $D6In, $D7In, $H0In, $H1In, $H2In, $H3In, $H4In, $H5In, $H6In, $H7In, $H8In, $H9In, $H10In, $H11In, $H12In, $H13In, $H14In, $H15In, $H16In, $H17In, $H18In, $H19In, $H20In, $H21In, $H22In, $H23In, $H24In, $TotalIn) = split(/\|/, $IN);

$UpD0In = 0;
$UpD1In = $D0In;
$UpD2In = $D1In;
$UpD3In = $D2In;
$UpD4In = $D3In;
$UpD5In = $D4In;
$UpD6In = $D5In;
$UpD7In = $D6In;

open(IN, ">$InDir/$i") &#0124; &#0124; &problem("Could Not Print $InDir/$i");
flock(IN, 2);
print IN "$In|$UpD0In|$UpD1In|$UpD2In|$UpD3In|$UpD4In|$UpD5In|$UpD6In|$UpD7In|$H0In|$H1In|$H2In|$H3In|$H4In|$H5In|$H6In|$H7In|$H8In|$H9In|$H10In|$H11 In|$H12In|$H13In|$H14In|$H15In|$H16In|$H17In|$H18In|$H19In|$H20In|$H21In|$H22In|$H23In|$H24In|$TotalIn|";
close(IN);
}

opendir (OUT, "$OutDir") &#0124; &#0124; &problem("Could Not Open $OutDir");
@filenames = grep (!/^\.\.?$/, readdir (OUT));
closedir (OUT);

foreach $i (@filenames) {
open(OUT, "$OutDir/$i") &#0124; &#0124; &problem("Could Not Open $OutDir/$i");
$OUT = <OUT>;
close(OUT);

($Out, $D0Out, $D1Out, $D2Out, $D3Out, $D4Out, $D5Out, $D6Out, $D7Out, $H0Out, $H1Out, $H2Out, $H3Out, $H4Out, $H5Out, $H6Out, $H7Out, $H8Out, $H9Out, $H10Out, $H11Out, $H12Out, $H13Out, $H14Out, $H15Out, $H16Out, $H17Out, $H18Out, $H19Out, $H20Out, $H21Out, $H22Out, $H23Out, $H24Out, $TotalOut) = split(/\|/, $OUT);

$UpD0Out = 0;
$UpD1Out = $D0Out;
$UpD2Out = $D1Out;
$UpD3Out = $D2Out;
$UpD4Out = $D3Out;
$UpD5Out = $D4Out;
$UpD6Out = $D5Out;
$UpD7Out = $D6Out;

open(OUT, ">$OutDir/$i") &#0124; &#0124; &problem("Could Not Open $OutDir/$i");
flock(OUT, 2);
print OUT "$Out|$UpD0Out|$UpD1Out|$UpD2Out|$UpD3Out|$UpD4Out|$UpD5Out|$UpD6Out|$UpD7Out|$H0Out|$H1Out|$H2Out|$H3Out|$H4Out|$H5Out|$H6Out|$H7Out|$H8Out |$H9Out|$H10Out|$H11Out|$H12Out|$H13Out|$H14Out|$H15Out|$H16Out|$H17Out|$H18Out|$H19Out|$H20Out|$H21Out|$H22Out|$H23Out|$H24Out|$TotalOut|";
close(OUT);
}
}

######################################
# Report any errors
#
sub problem {
$problems = $_[0] ;
print <<HTML;
<center>
<table border cellspacing="0" cellpadding="5" width="70%" bgcolor="#000000">
<tr align=center bgcolor="#AFAFAF">
<td align=center colspan="2">
<font face="Arial" size=-1>
<b>THERE HAS BEEN AN ERROR</b>
</td>
</tr>
<tr>
<td bgcolor="#DCDCDC" width="33%">
<font face="Arial" size="-2">
<b>ERROR DESCRIPTION:</b>
</td>
<td bgcolor="#FFFFFF">
<font face="Arial" size="-2" color="#ff3300">
$problems
</td>
</tr>
<tr>
<td bgcolor="#DCDCDC">
<font face="Arial" size="-2">
<b>CAUSE OF ERROR:</b>
</td>
<td bgcolor="#FFFFFF">
<font face="Arial" size="-2" color="#ff3300">
$!
</td>
</tr>
</table>
HTML
exit;
}

#########
sub PrintList {
opendir (INFO, "$InfoDir") &#0124; &#0124; &problem("Could Not Open $InfoDir");
@filenames = grep (!/^\.\.?$/, readdir (INFO));
closedir (INFO);
$num_of_files = @filenames;

foreach $i (@filenames) {
open (INFO, "$InfoDir/$i") &#0124; &#0124; &problem("Could Not Open $InfoDir/$i");
$INFO = <INFO>;
close (INFO);
$data_array{$i} = $INFO;
}

@sorted_data = sort {$data_array{$b} <=> $data_array{$a}} keys(%data_array);

$rank = 1;
$stop = 0;

open(HTMLFILE, ">$HtmlDir/index.html") &#0124; &#0124; &problem("Could Not Open $HtmlDir/index.html");
flock(HTMLFILE, 2);

open(HEADER, "$CgiDir/$header_file") &#0124; &#0124; &problem("Could Not Open $CgiDir/$header_file");
while(<HEADER> ) {
print HTMLFILE "$_";
}
close(HEADER);

print HTMLFILE qq|<table border="$RankTableBorder" cellspacing="$RankCellspacing" cellpadding="$RankCellpadding" width="$RankTableWidth">|;

print HTMLFILE qq|<tr bgcolor="$RankTitleBgColour">
<td align="center" width="5%">
<font face="$RankFontFace" size="-1"><b>NO.
</td>
<td align="center" width="85%">
<font face="$RankFontFace" size="-1"><b>SITE
</td>
<td align="center" width="10%">
<font face="$RankFontFace" size="-1"><b>MARK
</td>|;
print HTMLFILE "</tr>";

for ($s; $s <= $ListSize; $s++) {
if ($stop < $num_of_files) {
$stop++;
$user = $sorted_data[$s];

open (TEMP, "$InfoDir/$user") &#0124; &#0124; &problem("Could Not Open $InfoDir/$user");
$line = <TEMP>;
close (TEMP);

($mark, $title, $url, $descrip, $email, $banner, $password) = split (/\|/, $line);

if (($rank <= $ListSize) && ($data_array{$user} >= 1)) {
print HTMLFILE qq|<tr bgcolor="$list_bgcolor"><td align="center" width="5%"><font face="$RankFontFace" size="-1">$rank</td><td align="center" width="85%"><font face="$RankFontFace" size="-1">|;

print HTMLFILE qq|<a href="$CgiUrl/out.cgi?$user">|;

print HTMLFILE qq|$title</a><br>$descrip</td>
<td align="center" width="10%">
<font face="$RankFontFace" size="-1">$mark
</td>|;


print HTMLFILE qq|</tr>|;
}
}
$rank++;
}
print HTMLFILE qq|</table><p><font face="$RankFontFace" font size="-2">Last Updated: $curTime</font><p>|;


open(FOOTER, "$CgiDir/$footer_file") &#0124; &#0124; &problem("Could Not Open $CgiDir/$footer_file");
while(<FOOTER> ) {
print HTMLFILE "$_";
}
close(FOOTER);
close(HTMLFILE);
}
---------------------------------------------
Thanks for all help!!!
What should i do to make it possible to run?