#!/usr/bin/perl
use CGI ':standard';
$get = param("get");
$page = param("page");
$addr = param("addr");
$rate = param("rate");
if ($rate)
{
if (!$page || !$addr)
{
print "Content-type: text/html\n\n";
print "
ERROR:page, address or get unspecified";
exit;
}
if ($rate < 10) {
system "lockfile -0 -l 30 -s 0 /home/brejc8/public_html/mirror/list.lock";
system "sed s@\"${page}==${addr}.*\"@@ /home/brejc8/public_html/mirror/list >/home/brejc8/public_html/mirror/list.new";
system "cp /home/brejc8/public_html/mirror/list.new /home/brejc8/public_html/mirror/list";
system "rm -f /home/brejc8/public_html/mirror/list.lock";
print "Content-type: text/html\n\n";
print "
Thank you for your rating of the ${addr} mirror of ${page}.
Due to it's low rating the mirror has been removed.";
exit;
}
system "lockfile -0 -l 30 -s 0 /home/brejc8/public_html/mirror/list.lock";
system "sed s@\"${page}==${addr}==.*\"@\"${page}==${addr}==${rate}\"@ /home/brejc8/public_html/mirror/list >/home/brejc8/public_html/mirror/list.new";
system "cp /home/brejc8/public_html/mirror/list.new /home/brejc8/public_html/mirror/list";
system "rm -f /home/brejc8/public_html/mirror/list.lock";
print "Content-type: text/html\n\n";
print "
Thank you for your rating of the ${addr} mirror of ${page}";
exit;
}
if (!$get)
{
if (!$page || !$addr)
{
print "Content-type: text/html\n\n";
print "
ERROR:page, address or get unspecified";
exit;
}
$page =~ s@http:\/\/@@;
$addr =~ s@http:\/\/@@;
system "lockfile -0 -l 30 -s 0 /home/brejc8/public_html/mirror/list.lock";
system "sed s@\"${page}==${addr}==.*\"@@ /home/brejc8/public_html/mirror/list >/home/brejc8/public_html/mirror/list.new";
system "cp /home/brejc8/public_html/mirror/list.new /home/brejc8/public_html/mirror/list";
open (FH, ">> /home/brejc8/public_html/mirror/list");
print FH "$page==$addr==50\n";
close (FH);
system "rm -f /home/brejc8/public_html/mirror/list.lock";
print "Content-type: text/html\n\n";
print "
Thank you for your sumbition of ${page}";
exit;
}
$get =~ s@http:\/\/@@;
open (FH, "grep \"${get}==\" /home/brejc8/public_html/mirror/list |");
$address = ;
if ($address) {
print "Content-type: text/html\n\n";
print "";
system "cat /home/brejc8/public_html/original/make_head";
system "cat /home/brejc8/public_html/original/make_menu";
print "Mirror list:
";
while ($address) {
$rating = $address;
$rating =~ s/.*==//;
$address =~ s/==$rating//;
$address =~ s/.*==//;
if (eval($rating < 1)) { $rating = 1; }
if (eval($rating > 100)){ $rating = 100;}
$bad = eval($rating * 0.9 - 1);
$good = eval(100 -((100 - $rating) * 0.9 - 1));
if (eval($bad < 0)) { $bad = 0; }
if (eval($good > 100)){ $good = 100;}
$rating2 = eval(int($rating * 2));
$rating = eval(int($rating));
$address2 = substr($address,0,60);
if (!($address eq $address2)) {$address2= "${address2}...";}
print "| $address2 |
 |
${rating}% |
|
";
$address = ;
}
close(FH);
print "
You could add your own mirror for ${get}
";
system "cat /home/brejc8/public_html/original/make_foot";
print "";
exit;
}
else {
print "Content-type: text/html\n\n";
print "";
system "cat /home/brejc8/public_html/original/make_head";
system "cat /home/brejc8/public_html/original/make_menu";
print "No mirrors found!
You could add your own mirror for ${get}
";
system "cat /home/brejc8/public_html/original/make_foot";
print "";
close (FH);
exit;
}