\n~;
}
# Begin main page.
sub main_page {
&header;
print qq~
$version
\n~;
&link_count;
print qq~
(You may need to refresh page to see links list changes!)
\n~;
foreach (sort sortem @Links) {
my ($name, $url, $description, $added) = split('\n');
unless ($description eq 'no description') {
$description = qq~ \~ [ $description ]~; }
else {
$description = ''; }
print qq~- $name$description
\n~; }
print qq~ |
\n~;
&footer;
}
# Begin add link page.
sub add_link {
&header;
print qq~
\n~;
&footer;
}
# Begin link was added page.
sub link_added {
&error_report;
my ($description);
if ($link_description) { $description = "$link_description"; }
else { $description = 'no description'; }
open DB,">>$db" or die "Can't open file!";
print DB "$link_name\n$link_url\n$description\n$Date\n\n";
close DB;
&header;
print qq~
\n~;
unless (!$link_description) {
$description = qq~ \~ [ $description ]~; }
else {
$description = ''; }
print qq~$link_name$description
|
\n~;
&footer;
}
# Begin delete links page.
sub delete_links {
&error_report;
&header;
print qq~
\n~;
&link_count;
print qq~
Check As Many Links As You Wish To Delete
\n~;
&footer;
}
# Begin links were deleted page.
sub links_deleted {
&error_report;
if (@List1) {
my (%cnt, $cnt);
foreach (@Links,@List1) {
$cnt{$_}++; }
foreach (keys %cnt) {
push @{ $cnt{$_} != 2 ? \@List2 : next }, $_; }}
open DB,">$db" or die "Can't open file!";
foreach (sort sortem @List2) {
print DB "$_\n\n"; }
close DB;
&header;
print qq~
Selected Links Were Deleted
|
---|
Deleted Links Listed Below:
\n~;
foreach (@List1) {
my ($name, $url, $description, $added) = split('\n');
unless ($description eq 'no description') {
$description = qq~ \~ [ $description ]~; }
else {
$description = ''; }
print qq~$name$description \n~; }
print qq~ |
\n~;
&footer;
}
# Begin the error message page.
sub error_report {
my ($no_name, $bad_url, $no_links, $no_selected_links, $link_exists);
if ($do_add) {
foreach (@Links) {
my ($name, $url, $description, $added) = split('\n');
if ($link_url =~ /$url/i) { $link_exists = "
$name
$url"; }}
$no_name = 1 if ($do_add && !$link_name);
$bad_url = 1 if ($link_url !~ /^(ftp|http\:\/\/(.)*\.\w+|news\:(.)*\.\w+)/i); }
$no_links = 1 if ($delete && !@Links);
$no_selected_links = 1 if ($do_delete && !@List1);
if($no_name || $bad_url || $no_links || $no_selected_links || $link_exists) {
&header;
print qq~
\n~;
unless ($link_exists) {
if ($no_name) { print qq~- You did not enter a link name!
\n~; }}
if ($bad_url) { print qq~- The url you entered is either missing or invalid!
\n~; }
if ($link_exists) { print qq~- The link url associated with the name below already exists:$link_exists
\n~; }
if ($no_links) { print qq~- There are no links to delete!
\n~; }
if ($no_selected_links) { print qq~- You did not select any links to delete!
\n~; }
print qq~
|
\n~;
&footer; }
}
# Begin link count.
sub link_count {
my ($total, $s);
$total = 0;
foreach (@Links) { $total++; }
if ($total == 1) { $s = ''; }
else { $s = 's'; }
print qq~There Are
$total Link$s\n~;
}
# Begin case insensitive sort.
sub sortem {
our ($a,$b);
lc($a) cmp lc($b);
}
# Begin security.
sub secure {
&header;
print qq~
\n~;
&footer;
# Secure inner subroutine
# if ($pass eq $pwc) { &main_page; }
# else { &sub_secure; }
}
# Begin html footer.
sub footer {
print qq~
Secure Links pass=$pass pwc=$pwc