]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/CGI.pm
* Removed --sanitize and --no-sanitize, replaced with --plugin htmlscrubber
[git.ikiwiki.info.git] / IkiWiki / CGI.pm
index 067886c70d49c1eed93865b8f867584a73a06605..15e86651d419f64e4b8e48dd5797feaafe8057ef 100644 (file)
@@ -2,6 +2,7 @@
 
 use warnings;
 use strict;
+use IkiWiki;
 use IkiWiki::UserInfo;
 
 package IkiWiki;
@@ -12,7 +13,7 @@ sub page_locked ($$;$) { #{{{
        my $nonfatal=shift;
        
        my $user=$session->param("name");
-       return if length $user && is_admin($user);
+       return if defined $user && is_admin($user);
 
        foreach my $admin (@{$config{adminuser}}) {
                my $locked_pages=userinfo_get($admin, "locked_pages");
@@ -118,7 +119,7 @@ sub cgi_signin ($$) { #{{{
                                validate => sub {
                                        my $name=shift;
                                        length $name &&
-                                       $name=~/$wiki_file_regexp/ &&
+                                       $name=~/$config{wiki_file_regexp}/ &&
                                        ! userinfo_get($name, "regdate");
                                },
                        );
@@ -360,13 +361,6 @@ sub cgi_editpage ($$) { #{{{
        if (! $form->submitted || $form->submitted eq "Preview" || 
            ! $form->validate) {
                if ($form->field("do") eq "create") {
-                       if (exists $pagesources{lc($page)}) {
-                               # hmm, someone else made the page in the
-                               # meantime?
-                               print $q->redirect("$config{url}/".htmlpage($page));
-                               return;
-                       }
-                       
                        my @page_locs;
                        my $best_loc;
                        my ($from)=$form->param('from')=~/$config{wiki_file_regexp}/;
@@ -395,13 +389,20 @@ sub cgi_editpage ($$) { #{{{
                                        $dir=~s![^/]+/+$!!;
                                        push @page_locs, $dir.$page;
                                }
-
-                               @page_locs = grep {
-                                       ! exists $pagesources{lc($_)} &&
-                                       ! page_locked($_, $session, 1)
-                               } @page_locs;
                        }
 
+                       @page_locs = grep {
+                               ! exists $pagesources{lc($_)} &&
+                               ! page_locked($_, $session, 1)
+                       } @page_locs;
+                       
+                       if (! @page_locs) {
+                               # hmm, someone else made the page in the
+                               # meantime?
+                               print $q->redirect("$config{url}/".htmlpage($page));
+                               return;
+                       }
+                               
                        $form->tmpl_param("page_select", 1);
                        $form->field(name => "page", type => 'select',
                                options => \@page_locs, value => $best_loc);
@@ -483,26 +484,21 @@ sub cgi_editpage ($$) { #{{{
        }
 } #}}}
 
-sub cgi_hyperestraier () { #{{{
-       # only works for GET requests
-       chdir("$config{wikistatedir}/hyperestraier") || error("chdir: $!");
-       exec("./".basename($config{cgiurl})) || error("estseek.cgi failed");
-} #}}}
-
 sub cgi () { #{{{
        eval q{use CGI};
        eval q{use CGI::Session};
        
        my $q=CGI->new;
        
+       if (exists $hooks{cgi}) {
+               foreach my $id (keys %{$hooks{cgi}}) {
+                       $hooks{cgi}{$id}{call}->($q);
+               }
+       }
+       
        my $do=$q->param('do');
        if (! defined $do || ! length $do) {
-               if (defined $q->param('phrase')) {
-                       cgi_hyperestraier();
-               }
-               else {
-                       error("\"do\" parameter missing");
-               }
+               error("\"do\" parameter missing");
        }
        
        # Things that do not need a session.