#!/usr/bin/perl
################
# basic set up #
################
#$url = "http://your_url/";
#$dir = "/your_directory/public_html/";
#$smpath = "/usr/sbin/sendmail";
$addrss = 'your@mail.address';
$tool = "admin";
$pswd = "your_password";
$lfile = "link.html";
$tfile = "temp.dat";
$lock = 20;
$exprs = 600;
$erro0 = "This is not an error.";
$erro1 = "Someone is adding a link to LazyLinksLimited right now.";
$erro2 = "If it persists, please inform the webmaster.";
$erro3 = "Fail to handle data/working file.";
$erro4 = "The CGI stalled. This may be serious.";
$erro5 = "You may retry but if it fails please inform the webmaster.";
$erro6 = "Fail to handle directory.";
$erro7 = "Unknown command or wrong password.";
if ($ENV{'SERVER_NAME'}) {
$self = "http://".$ENV{'SERVER_NAME'}.$ENV{'SCRIPT_NAME'};
} else {
$self = $ENV{'SCRIPT_NAME'};
}
if (!$url) {($url = $self) =~ s/[^\/]*$//;}
$url .= $lfile;
$lock = $lock/86400;
###############
# main script #
###############
if ($ENV{'QUERY_STRING'} eq $tool) {
&tool;
} elsif ($ENV{'REQUEST_METHOD'} ne 'POST') {
print "Location: $url\n\n";
} else {
### get input ###
read(STDIN, $input, $ENV{'CONTENT_LENGTH'});
@pair = split(/&/, $input);
foreach (@pair) {
($name, $value) = split(/=/);
$value =~ tr/+/ /;
$value =~ s/%0D%0A/
/g;
$value =~ s/%0A/
/g;
$value =~ s/%0D/
/g;
$value =~ s/%09/ /g;
$value =~ s/%3C/</g;
$value =~ s/%3E/>/g;
$value =~ s/%(..)/pack("c", hex($1))/ge;
$data{$name} = $value;
}
if ($data{'do'} ne "edit") {
&addurl;
} elsif ($data{'pswd'} eq $pswd) {
&edit;
} else {
&error1($erro7);
}
}
exit;
###########
# add url #
###########
sub addurl
{
### data preparation ###
$newd = <<"NEW_URL";
$data{'title'}
Dear Guest,
Your command has been averted due :
$data{'descript'}
NEW_URL
$newd =~ s/[\t\n\r\f]/ /g;
$newd = "\t".$newd;
$group = $data{'group'};
&open;
&lock;
### add new link ###
while (This is the webmaster's administrative page.
If you are here by mistake,
If you are here to hack the site, please don't.
LazyLinksLimited is Here.
PLEASE ENTER
Hello there!
$thank
You may need to click the reload button to see the latest change on the link page.
THANKS
}
#####################
# Error No1 message #
#####################
sub error1
{
print <<"ERROR_M";
Content-type: text/html
$_[0]
$_[1]
$_[2]
$_[3]
ERROR_M
exit;
}
#####################
# Error No2 message #
#####################
sub error2
{
unlink $tfile or &error1($_[0],$erro4,$erro5,$!);
&error1;
}
#-- End of link.cgi
#
# LazyLinksLimited, Version 2
# visitware (C) 1999-2002 B. Uchina
# All rights reserved
# http://www.visitware.com/sobaya/