Leser: 1
7 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/perl
use strict;
use warnings;
use CGI qw( :all );
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
# Initialisierung
my $cgi = new CGI;
my %params = $cgi->Vars();
my $file = '/SAN/content/cgi-bin/links';
my $save_error = "";
# Parameter pruefen
foreach ( keys %params ) {
}
# Linkliste erstellen
sub create_linklist {
open ( F, ">", $file ) || die "could not create $file. $!";
print F "#" x80, "\n";
printf F "# Linklist created %s.\n", scalar localtime ( time );
close F;
}
# Speichern des neuen Links wenn einer eingetragen wurde.
if ( defined $params{write} && $params{write} eq "true" ) {
$params{text} =~ s/\r\n/<br>/sg;
if (! -f $file ) {
&create_linklist;
}
else {
if ( $params{url} =~ /^http:\/\/.*$/ ) {
open ( D, '>>', $file ) or die "Could not save data. $!";
print D "#" x80, "\n$params{url}\n$params{text}\n";
close D;
}
else {
$save_error = "<p>Bitte geben Sie den kompletten URL an, sonst kann ";
$save_error .= "Ihr Link nicht gespeichert werden.<br /> Beispiel: ";
$save_error .= "http://ihr.neuer.link.com/</p>";
}
}
}
# Laden der Linkliste
my @links;
if (! -f $file ) {
&create_linklist;
}
else {
open ( F, '<', $file ) || die "Could not open $file. $!";
@links = grep { /^http/ } <F>;
close F;
foreach ( @links ) { chomp ( $_ ); }
}
# Ausgabe der Seite
my $author = "Andre Hornig";
print $cgi->header(),
$cgi->start_html(
-title => "Linkit - Eine kleine Favoritenliste.",
-bgcolor => "#99ccff",
'Linkit'
),
$cgi->h1('Linkit'),
$cgi->p({-style => 'color:red'}, "Verfasst von: ", $cgi->i($author)),
$cgi->hr({-noshade => undef, -size => '1'}),
$cgi->p('Eine kleine Favoritenliste');
foreach ( @links ) { print $cgi->p('',$cgi->a( {-href => $_}, $_ ) ); }
print $cgi->hr({-noshade => undef, -size => '1'});
print << "EOF";
<h1>Neuen Link eintragen</h1>
$save_error
<form action="" method="post">
<p>
Link:<br />
<input type="text" name="url" size="40" maxlength="40" />
</p>
<p>
Beschreibung:<br />
<textarea rows="5" cols="50" name="text"></textarea>
<input type=hidden name="write" value="true" />
</p>
<p><input type="submit" value="Absenden" /></p>
</form>
EOF
$cgi->end_html();
foreach ( @links ) { print $cgi->p('',$cgi->a( {-href => $_}, $_ ) ); }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/perl
use strict;
use warnings;
use CGI qw( :all );
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
# Initialisierung
my $cgi = new CGI;
my %params = $cgi->Vars();
my $file = '/SAN/content/cgi-bin/links';
my $save_error = "";
# Parameter pruefen
foreach ( keys %params ) {
}
# Linkliste erstellen
sub create_linklist {
open ( F, ">", $file ) || die "could not create $file. $!";
print F "#" x80, "\n";
printf F "# Linklist created %s.\n", scalar localtime ( time );
close F;
}
# Speichern des neuen Links wenn einer eingetragen wurde.
if ( defined $params{write} && $params{write} eq "true" ) {
$params{text} =~ s/\r?\n/<br>/sg;
if (! -f $file ) {
&create_linklist;
}
else {
if ( $params{url} =~ /^http:\/\/.*$/ ) {
open ( D, '>>', $file ) or die "Could not save data. $!";
print D "#" x80, "\n$params{url}\n$params{text}\n";
close D;
}
else {
$save_error = "<p>Bitte geben Sie den kompletten URL an, sonst kann ";
$save_error .= "Ihr Link nicht gespeichert werden.<br /> Beispiel: ";
$save_error .= "http://ihr.neuer.link.com/</p>";
}
}
}
# Laden der Linkliste
my @links;
# Ausgabe der Seite
my $author = "Andre Hornig";
print $cgi->header(),
$cgi->start_html(
-title => "Linkit - Eine kleine Favoritenliste.",
-bgcolor => "#99ccff",
'Linkit'
),
$cgi->h1('Linkit'),
$cgi->p({-style => 'color:red'}, "Verfasst von: ", $cgi->i($author)),
$cgi->hr({-noshade => undef, -size => '1'}),
$cgi->p('Eine kleine Favoritenliste');
if (! -f $file ) {
&create_linklist;
}
else {
my $url = "";
open ( F, '<', $file ) || die "Could not open $file. $!";
while(my $line = <F>){
chomp $line;
if($. % 2 == 0){
print $cgi->p('',$cgi->a( {-href => $url}, $line ) );
}
else{
$url = $line;
}
close F;
}
print $cgi->hr({-noshade => undef, -size => '1'});
print << "EOF";
<h1>Neuen Link eintragen</h1>
$save_error
<form action="" method="post">
<p>
Link:<br />
<input type="text" name="url" size="40" maxlength="40" />
</p>
<p>
Beschreibung:<br />
<textarea rows="5" cols="50" name="text"></textarea>
<input type=hidden name="write" value="true" />
</p>
<p><input type="submit" value="Absenden" /></p>
</form>
EOF
$cgi->end_html();
1
2
3
4
5
6
7
8
9
10
11
while(my $line = <F>){
chomp $line;
next unless($. >=2 );
if($. % 2 == 0){
print $cgi->p('',$cgi->a( {-href => $url}, $line ) );
}
else{
$url = $line;
}
}
close F;
1
2
3
4
5
6
7
8
9
while(my $line = <F>){
chomp $line;
if($. % 2 == 0){
print $cgi->p('',$cgi->a( {-href => $url}, $line ) );
}
else{
$url = $line;
}
close F;
7 Einträge, 1 Seite |