#!/usr/bin/perl
###############################
# Hot Links 1.0 Lite index.cgi
# Created by Mike Ramirez
# Nothing below here is configurable
###############################
require 'headerfooter.pl';
require 'config.pl';
##################################################
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($key, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/[\;\|\\ ]/ /ig;
$FORM{$key} = $value;
}
##################################################
print "Content-type: text/html\n\n";
&header;
if ($cuttoff == 0) {
print "
順不同。なお当サイトは無断リンク歓迎(ないと思うけど)
";
}
print <<"HTML";
HTML
# Get category list
open (FILE, "$catfilepath");
@catsx = ;
close(FILE);
foreach $cat (@catsx) {
@catline = split(/\|/, $cat);
$catsy{$catline[1]} = $catline[0];
}
foreach $key (sort keys %catsy) { #alphabetize categories
#print "$key => $catsy{$key}"; used for testing...
push(@cats, "$catsy{$key}|$key");
}
open (FILE2, "$datafilepath");
@newlinkstemp = ;
close(FILE2);
@newlinks = sort {$b <=> $a} @newlinkstemp; #reverse link order, new links at the top
foreach $line (@cats) {
@catinfo = split(/\|/, $line);
$switch = 0; # switch to determine whether a category has any link or not.
$current = 1; # count used to determine how many links have been displayed
$catcount = 0;
foreach $link (@newlinks) {
@forcount = split(/\|/, $link);
if ($forcount[1] == $catinfo[0]) {
$catcount = ++$catcount;
}
}
print "[$catcount] | ";
foreach $link (@newlinks) {
@linkinfo = split(/\|/, $link);
if ($current <= $cutoff) {
if ($linkinfo[1] == $catinfo[0]) {
print "$linkinfo[2] | ";
$switch = 1;
$current = ++$current;
}
} elsif ($current == ($cutoff +1)) {
if ($linkinfo[1] == $catinfo[0]) {
if ($cutoff == 0) {
print "View $catinfo[1] Links | ";
} else {
print "click here for more $catinfo[1] Links | ";
}
$switch = 1;
$current = ++$current;
}
} else {
$current = ++$current;
}
}
$current = 1;
if ($switch == 0) {
print "No Links | ";
}
}
print <<"HTML";
|
HTML
######################
open (FILE, "$datafilepath");
@linkstocount = ;
close(FILE);
foreach $line (@linkstocount) {
$totallinkcount = ++$totallinkcount;
}
print <<"HTML";
|
Now listing $totallinkcount different links.
HTML
&footer;