#!/usr/bin/perl -w
use strict; use CGI ':standard';
(my $word, my $action) = map { $_ =~ s/(?:[a-z]+=)||[^A-Za-z]//g; $_ } split /\&/, $ENV{QUERY_STRING};
my $sn = './'; $word ||= 'Home'; $action ||= 'view'; # $ENV{SCRIPT_NAME}
my $form = "$sn?$word&action=save"; print header(-type=>'text/html',-charset=>'utf-8'),
start_html(-title=>"WWW: $word",-style=>{-src =>'style.css'});
sub save { open my $f, '>'.$_[0]; print $f $_[1]; close $f; }
-f $word or do { $action = 'edit'; save($word, "$word has been created."); };
my $text; sub readword { @ARGV = ($word); $text = "\n" . join '', <>; } readword();
$action eq 'edit' and print h3('Editing', $word),start_form(-action=>$form),
textarea('text',$text,20,80),br,submit,end_form,end_html() and exit 0;
$action eq 'save' and do { save($word, param('text')); readword(); };
my $state = 0; $state == 0 && $text =~ m/\G\n/cgs or
$text =~ m/\G(\[\[)(.+?)(\/\/)(.+?)(\]\])/cgs && print a({-href=>"$sn?$2"},"$4") or
$text =~ m/\G(\[)(http\:\/\/\S+)(\/\/)(.+?)(\])/cgs && print a({-href=>"$2"},"$4") or
$text =~ m/\G(img:)(.+?\S+)/cgs && print img({src=>"$2",alt=>"$2"}) or
$text =~ m/\G(.+?)/cgs && print("$1") or
print "\n",hr,a({-href=>"$sn"},"Home"),' ',a({-href=>"$sn?$word&action=edit"},"Edit"),
end_html() and last while 1;
Name:
Anonymous2009-02-20 5:43
>>6
You say 1998, but you still have a charset in there.
Name:
Anonymous2009-02-20 6:34
No RCS, no password system. Some would call it a Wiki in name only.
Name:
Anonymous2009-02-20 11:06
fuck wiki, password and it's a neat little CMS using XHTML code as markup just like God intended
Name:
Anonymous2009-02-20 11:56
>>8
What is a Wiki? A miserable pile of Perl, that's what!
Name:
Anonymous2009-02-21 19:25
#!/usr/bin/perl -w
use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser);
(my $word, my $action) = map { $_ =~ s/(?:[a-z]+=)||[^A-Za-z]//g; $_ } split /\&/, $ENV{QUERY_STRING};
my $sn = $ENV{SCRIPT_NAME}; $word ||= 'Home'; $action ||= 'view';
my $form = "$sn?$word"; print header(-type=>'text/html',-charset=>'utf-8'),
start_html(-title=>"WWW: $word",-style=>{-src =>'style.css'});
sub save { open my $f, '>'.$_[0]; print $f $_[1]; close $f; }
my $password = "this pass SO cash"; my $pwd = param("pass"); if(-f $word){}
elsif((request_method() eq "POST") && (escapeHTML($pwd) eq $password))
{ save($word, "$word created."); } else { $action = 'create'; }
$action eq 'create' and print h3('Create', $word),br,
start_form(),password_field('pass'),submit,end_form,end_html() and exit 0;
my $text; sub readword { @ARGV = ($word); $text = "\n" . join '', <>; } readword();
$action eq 'edit' and print h3('Edit', $word),start_form(-action=>$form),
textarea('text',$text,20,80),"\n",br,password_field('pass'),submit,end_form,end_html() and exit 0;
{my $state = 0; $state == 0 && $text =~ m/\G\n/cgs or
$text =~ m/\G(\[\[)(.+?)(\/\/)(.+?)(\]\])/cgs && print a({-href=>"$sn?$2"},"$4") or
$text =~ m/\G(\[)(http\:\/\/\S+)(\/\/)(.+?)(\])/cgs && print a({-href=>"$2",-class=>"ex"},"$4") or
$text =~ m/\G(img:)(.+?\S+)/cgs && print img({src=>"$2",alt=>"$2"}) or
$text =~ m/\G(.+?)/cgs && print("$1") or
print "\n",hr,a({-href=>"$sn"},"Home"),' ',a({-href=>"$sn?$word&action=edit"},"Edit"),
end_html() and last while 1;}
if((request_method() eq "POST") && (escapeHTML($pwd) eq $password))
{ save($word, param('text')); readword(); }
I'm not a programmer or learning to program, but I like to hang out here. How's this for someone who got all his info from Google searching? it took me an hour to realize it was elsif and not elseif :(