#!/usr/bin/perl
use strict;
use warnings;
use CGI qw( :all );
use CGI::Carp qw(fatalsToBrowser);
my $cgi = new CGI;
my %params = $cgi->Vars();
print $cgi->header();
my $Autor = "Andre Hornig";
print $cgi->default_dtd('-//W3C//DTD HTML 4.01 Transitional//EN'),
$cgi->start_html('Linkit'),
$cgi->h1('Linkit'),
$cgi->p('Eine kleine Favoritenliste'),
$cgi->p({-style => 'color:red'}, "Verfasst von: ",
$cgi->i($Autor)),
$cgi->hr({-noshade => undef, -size => '1'});
if($params{action} == 1){
save_link(\%params);
}
show_links();
print $cgi->end_html();
sub save_link{
my ($paramref) = @_;
my $pfad = '/SAN/content/cgi-bin/links';
my $url = $paramref->{'links'};
my $text = $paramref->{'beschreibung'};
$text =~ s/\r?\n/
/sg;
open(DATEI,'>>',$pfad) or die $!;
print DATEI "$url\n";
print DATEI "$text\n";
close (DATEI) or die $!;
}
sub show_links{
#File einlesen und in ein Array speichern.
my $link;
my $pfad = '/SAN/content/cgi-bin/links';
open(DATEI, '<', $pfad) or die $!;
while(my $line = ){
if($. % 2 == 0){
print $cgi->p('',$cgi->a({-href => $link},$zeile));
}
else{
$link = $line;
}
close(DATEI);
#Ausgabe der Seite
print <<"EOF";
Neuen Link eintragen
EOF
}