Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/local/bin/perl -w use diagnostics; use strict; use CGI; use HTML::Entities; #anomolie. no blank pages, no zeroes, ask the perl gods. my $c = new CGI; dbmopen(my %WIKI, "wiki", 0644); my(@p, $p, $q, $error); @p = $c->param; $p = (defined $p[0] and $p[0] eq "keywords" ? $c->param("keywords") : +$p[0]) || "WelcomePage"; $error = ($p !~ /^(search|edit)?([A-Z][a-z]+([A-Z][a-z]+)+)/ ? "Invali +dAction" : ""); $q = $p; $q =~ s/^[a-z]+(.*)/$1/; $WIKI{"$q"} = scalar(encode_entities($c->param($p))) if $p =~ /^edit/ +and defined(scalar($c->param($p))) and !($error); $WIKI{"$q"} =~ s/\&\#13\;//g if $WIKI{"$q"}; $p = $q if $p =~ /^edit/ and $c->param($p); print "Content-Type: text/html; charset=UTF-8\n\n", $c->start_html(-ti +tle=>$p), $c->h1($c->a({-href=>"/wiki/"},"HtmlismOpenWiki")." : ".($p + =~ /^edit/ ? $c->a({-href=>"?$q"},$p) : ($p =~ /^search/ ? $c->a({-h +ref=>"?$q"},$p) : $c->a({-href=>"?search$q"},$p)))); if ($p =~ /^edit.*/ and not $error and not $c->param($p)) { print $c->startform("post","/wiki/"), $c->textarea({-style=>"width:100%;height:3in",-name=>"$p",-default +=>($WIKI{$q} ? $WIKI{$q} : "")}), $c->p($c->submit), $c->endform } print wikimake(($error ? $c->p($error) : "")), wikimake(($WIKI{$q} && +($p =~ /^[A-Z]/ or $c->param($p)) ? $c->p($WIKI{$q}) : "")), ((($p =~ + /^[A-Z]/ or $c->param($p)) and !$error) ? ($c->hr.$c->p($c->a({-href +=>"?edit$q"},"Edit this page"))) : ""), $c->end_html; dbmclose(%WIKI); sub wikimake { my $z = shift; $z =~ s/\b([A-Z][a-z]+([A-Z][a-z]+)+)/$c->a({-href=>"?$1"},$1)/eg; $z =~ s/\n/$c->br/eg; return $z; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: Vanishing Data
by jeffa (Bishop) on May 02, 2002 at 02:41 UTC | |
by thelenm (Vicar) on May 02, 2002 at 16:31 UTC | |
|
Re: Vanishing Data
by dws (Chancellor) on May 02, 2002 at 02:45 UTC | |
by Anonymous Monk on May 04, 2002 at 15:45 UTC | |
|
Re: Vanishing Data
by Anonymous Monk on May 02, 2002 at 16:40 UTC |