#!/usr/bin/perl ############################################################### # # # Any use of this program is entirely at the risk of the # # user. No liability will be accepted by the author. # # # # This code must not be distributed or sold, even in modified # # form, without the written permission of the author. # # # ############################################################### ############################################################### # # # Nothing below needs to be modified. You can apply # # modifications if you know what you are doing. Remember that # # all credits must remain intact. # # # ############################################################### # Locate and load required files eval { # Get the script location (for UNIX and Windows) ($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location (for Windows) ($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Load files require "settings.cgi"; require "common.sub"; }; # Initialize start position $FORM{'startat'} = 0; # Read the form &readform; # Get update, reset, clearance times require "$membpath/timer.log"; # Get current time $curtime = time(); # Set internal script reference $fromscript = 1; # Reset IP Log require "$path/ipreset.cgi" if (!$usecrontab && $iptime && $curtime - $iplog >= $iptime); # Reset member stats require "$path/reset.cgi" if (!$usecrontab && $restime && $curtime - $reset >= $restime); # Update Top List require "$path/update.cgi" if (!$usecrontab && $updtime && $curtime - $update >= $updtime); # Read the rankings open(RANKINGS,"$membpath/lastupdate.log") || err("Could not update $membpath/lastupdate.log: $!"); @ranklist = ; close(RANKINGS); chomp(@ranklist); # Get the total number of sites $totsites = scalar(@ranklist); # Check if start position is valid $FORM{'startat'} = 0 if $FORM{'startat'} < 0 || $FORM{'startat'} >= $totsites; # Format dates $last_update = &getdate($update, 1); $next_reset = &getdate($reset + $restime, 1) if $restime; # Load common vocabulary require "$tmplpath/common.txt"; # Load Top List template require "$tmplpath/index.tmpl"; # Total number of sites $TOT_SITES_SUB = qq($tempvoc[0] $totsites); # Date of last update $UPD_DATE_SUB = qq($tempvoc[1] $last_update); # Date of next reset $RES_DATE_SUB = qq($tempvoc[2] $next_reset) if $restime; # Member Area link $MEMB_LINK_SUB = qq($tempvoc[3]); # Registration link $REG_LINK_SUB = qq($tempvoc[4]); # Column span of Rank $rank_span = 1 + $showimgindicator + $showtxtindicator; # Build Top List rows if (@ranklist) { # Initialize background row color $tmprowbg = $topprimcolor; # Loop through rankings list $endpos = $FORM{'startat'} + $sitesperpage - 1; $endpos = $totsites - 1 if $endpos >= $totsites; for ($i = $FORM{'startat'}; $i <= $endpos; $i++) { # Get member info @tmprankinfo = split(/\t/, $ranklist[$i]); # Position change graphic indicator if ($showimgindicator) { $poschange = $tmprankinfo[2] - $tmprankinfo[1]; if ($tmprankinfo[2] && $poschange > 0) { $tmpgraphic = $gainimg; } elsif ($tmprankinfo[2] && $poschange < 0){ $tmpgraphic = $lostimg; } else { $tmpgraphic = $nochangeimg; } $tmpimgindicator = qq(
); } # Position change text indicator if ($showtxtindicator) { $poschange = $tmprankinfo[2] - $tmprankinfo[1]; if ($tmprankinfo[2] && $poschange > 0) { $tmpcolor = $gaincolor; $poschange = "+" . $poschange; } elsif ($tmprankinfo[2] && $poschange < 0){ $tmpcolor = $lostcolor; } else { $tmpcolor = $nochangecolor; $poschange = "-"; } $tmptxtindicator = qq(
$poschange
); } # Flag $tmpflag = qq($tmprankinfo[3] ) if $showflag; # Rate It! link $tmprateit = qq($commonvoc[51]) if $showrateit; # In $tmpin = qq(
$tmprankinfo[6]
) if $showin; # Out $tmpout = qq(
$tmprankinfo[7]
) if $showout; # Total hits $tmphitscalc = $tmprankinfo[6] + $tmprankinfo[7]; $tmphits = qq(
$tmphitscalc
) if $showhits; # Votes $tmpvotes = qq(
$tmprankinfo[8]
) if $showvotes; # Rating $tmprating = sprintf("
%.2f
", $tmprankinfo[9]) if $showrating; # Score $tmpscore = qq(
$tmprankinfo[10]
) if $showscore; # Complete row $tmprows .= qq(
$tmprankinfo[1]
$tmpimgindicator $tmptxtindicator
$tmpflag$tmprankinfo[4]
$tmprankinfo[5]
$tmprateit
$tmpin $tmpout $tmphits $tmpvotes $tmprating $tmpscore ); # Switch background row color if ($tmprowbg eq $topprimcolor) { $tmprowbg = $topseconcolor; } else { $tmprowbg = $topprimcolor; } } } else { # Total column span $totspan = 2 + $showimgindicator + $showtxtindicator + $showin + $showout + $showhits + $showvotes + $showrating + $showscore; # Nothing to display $tmprows = qq(
$tempvoc[6]
); } # Top List table $TOP_LIST_SUB = qq( ); $TOP_LIST_SUB .= qq( ) if $showin; $TOP_LIST_SUB .= qq( ) if $showout; $TOP_LIST_SUB .= qq( ) if $showhits; $TOP_LIST_SUB .= qq( ) if $showvotes; $TOP_LIST_SUB .= qq( ) if $showrating; $TOP_LIST_SUB .= qq( ) if $showscore; $TOP_LIST_SUB .= qq( $tmprows
$commonvoc[44]
$tempvoc[5]
$commonvoc[45]
$commonvoc[46]
$commonvoc[47]
$commonvoc[48]
$commonvoc[49]
$commonvoc[50]
); if ($totsites) { # Viewing position indicator $POS_IND_SUB = sprintf("$commonvoc[52] %d - %d $commonvoc[53] %d.", $FORM{'startat'} + 1, $endpos + 1, $totsites); # Page breakdown links $PAGE_LINKS_SUB = qq($commonvoc[54]); $startpos = 0; $pagenum = 1; while ($startpos < $totsites) { if ($startpos eq $FORM{'startat'}) { $PAGE_LINKS_SUB .= qq( [$pagenum]); } else { $PAGE_LINKS_SUB .= qq( [$pagenum]); } $startpos += $sitesperpage; $pagenum++; } $PAGE_LINKS_SUB .= ""; } # Perform template substitutions $temphtml =~ s/\{TOT_SITES\}/$TOT_SITES_SUB/g; $temphtml =~ s/\{UPD_DATE\}/$UPD_DATE_SUB/g; $temphtml =~ s/\{RES_DATE\}/$RES_DATE_SUB/g; $temphtml =~ s/\{MEMB_LINK\}/$MEMB_LINK_SUB/g; $temphtml =~ s/\{REG_LINK\}/$REG_LINK_SUB/g; $temphtml =~ s/\{TOP_LIST\}/$TOP_LIST_SUB/g; $temphtml =~ s/\{POS_IND\}/$POS_IND_SUB/g; $temphtml =~ s/\{PAGE_LINKS\}/$PAGE_LINKS_SUB/g; &logstatus; # Display the screen &showscreen;