]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/CGI.pm
oops
[git.ikiwiki.info.git] / IkiWiki / CGI.pm
1 #!/usr/bin/perl
3 use warnings;
4 use strict;
5 use IkiWiki;
6 use IkiWiki::UserInfo;
7 use open qw{:utf8 :std};
8 use Encode;
10 package IkiWiki;
12 sub printheader ($) { #{{{
13         my $session=shift;
14         
15         if ($config{sslcookie}) {
16                 print $session->header(-charset => 'utf-8',
17                         -cookie => $session->cookie(-secure => 1));
18         } else {
19                 print $session->header(-charset => 'utf-8');
20         }
22 } #}}}
24 sub redirect ($$) { #{{{
25         my $q=shift;
26         my $url=shift;
27         if (! $config{w3mmode}) {
28                 print $q->redirect($url);
29         }
30         else {
31                 print "Content-type: text/plain\n";
32                 print "W3m-control: GOTO $url\n\n";
33         }
34 } #}}}
36 sub check_canedit ($$$;$) { #{{{
37         my $page=shift;
38         my $q=shift;
39         my $session=shift;
40         my $nonfatal=shift;
41         
42         my $canedit;
43         run_hooks(canedit => sub {
44                 return if defined $canedit;
45                 my $ret=shift->($page, $q, $session);
46                 if (defined $ret && $ret eq "") {
47                         $canedit=1;
48                 }
49                 elsif (defined $ret) {
50                         $canedit=0;
51                         error($ret) unless $nonfatal;
52                 }
53         });
54         return $canedit;
55 } #}}}
57 sub decode_form_utf8 ($) { #{{{
58         my $form = shift;
59         foreach my $f ($form->field) {
60                 next if Encode::is_utf8(scalar $form->field($f));
61                 $form->field(name  => $f,
62                              value => decode_utf8($form->field($f)),
63                              force => 1,
64                             );
65         }
66 } #}}}
68 sub cgi_recentchanges ($) { #{{{
69         my $q=shift;
70         
71         # Optimisation: building recentchanges means calculating lots of
72         # links. Memoizing htmllink speeds it up a lot (can't be memoized
73         # during page builds as the return values may change, but they
74         # won't here.)
75         eval q{use Memoize};
76         error($@) if $@;
77         memoize("htmllink");
79         eval q{use Time::Duration};
80         error($@) if $@;
82         my $changelog=[rcs_recentchanges(100)];
83         foreach my $change (@$changelog) {
84                 $change->{when} = concise(ago($change->{when}));
86                 $change->{user} = userlink($change->{user});
88                 my $is_excess = exists $change->{pages}[10]; # limit pages to first 10
89                 delete @{$change->{pages}}[10 .. @{$change->{pages}}] if $is_excess;
90                 $change->{pages} = [
91                         map {
92                                 $_->{link} = htmllink("", "", $_->{page},
93                                         noimageinline => 1,
94                                         linktext => pagetitle($_->{page}));
95                                 $_;
96                         } @{$change->{pages}}
97                 ];
98                 push @{$change->{pages}}, { link => '...' } if $is_excess;
99         }
101         my $template=template("recentchanges.tmpl"); 
102         $template->param(
103                 title => "RecentChanges",
104                 indexlink => indexlink(),
105                 wikiname => $config{wikiname},
106                 changelog => $changelog,
107                 baseurl => baseurl(),
108         );
109         run_hooks(pagetemplate => sub {
110                 shift->(page => "", destpage => "", template => $template);
111         });
112         print $q->header(-charset => 'utf-8'), $template->output;
113 } #}}}
115 # Check if the user is signed in. If not, redirect to the signin form and
116 # save their place to return to later.
117 sub needsignin ($$) { #{{{
118         my $q=shift;
119         my $session=shift;
121         if (! defined $session->param("name") ||
122             ! userinfo_get($session->param("name"), "regdate")) {
123                 if (! defined $session->param("postsignin")) {
124                         $session->param(postsignin => $ENV{QUERY_STRING});
125                 }
126                 cgi_signin($q, $session);
127                 cgi_savesession($session);
128                 exit;
129         }
130 } #}}}  
132 sub cgi_signin ($$) { #{{{
133         my $q=shift;
134         my $session=shift;
136         eval q{use CGI::FormBuilder};
137         error($@) if $@;
138         my $form = CGI::FormBuilder->new(
139                 title => "signin",
140                 header => 1,
141                 charset => "utf-8",
142                 method => 'POST',
143                 required => 'NONE',
144                 javascript => 0,
145                 params => $q,
146                 action => $config{cgiurl},
147                 header => 0,
148                 template => scalar template_params("signin.tmpl"),
149                 stylesheet => baseurl()."style.css",
150         );
151         my $buttons=["Login"];
152         
153         if ($q->param("do") ne "signin" && !$form->submitted) {
154                 $form->text(gettext("You need to log in first."));
155         }
156         $form->field(name => "do", type => "hidden", value => "signin",
157                 force => 1);
158         
159         run_hooks(formbuilder_setup => sub {
160                 shift->(form => $form, cgi => $q, session => $session);
161         });
162         
163         decode_form_utf8($form);
165         if (exists $hooks{formbuilder}) {
166                 run_hooks(formbuilder => sub {
167                         shift->(form => $form, cgi => $q, session => $session,
168                                 buttons => $buttons);
169                 });
170         }
171         else {
172                 if ($form->submitted) {
173                         $form->validate;
174                 }
175                 printheader($session);
176                 print misctemplate($form->title, $form->render(submit => $buttons));
177         }
178 } #}}}
180 sub cgi_postsignin ($$) { #{{{
181         my $q=shift;
182         my $session=shift;
183         
184         # Continue with whatever was being done before the signin process.
185         if (defined $session->param("postsignin")) {
186                 my $postsignin=CGI->new($session->param("postsignin"));
187                 $session->clear("postsignin");
188                 cgi($postsignin, $session);
189                 cgi_savesession($session);
190                 exit;
191         }
192         else {
193                 # This can occur, for example, if a user went to the signin
194                 # url via a bookmark.
195                 redirect($q, $config{url});
196         }
197 } #}}}
199 sub cgi_prefs ($$) { #{{{
200         my $q=shift;
201         my $session=shift;
203         needsignin($q, $session);
205         eval q{use CGI::FormBuilder};
206         error($@) if $@;
207         my $form = CGI::FormBuilder->new(
208                 title => "preferences",
209                 header => 0,
210                 charset => "utf-8",
211                 method => 'POST',
212                 validate => {
213                         email => 'EMAIL',
214                 },
215                 required => 'NONE',
216                 javascript => 0,
217                 params => $q,
218                 action => $config{cgiurl},
219                 template => scalar template_params("prefs.tmpl"),
220                 stylesheet => baseurl()."style.css",
221         );
222         my $buttons=["Save Preferences", "Logout", "Cancel"];
224         run_hooks(formbuilder_setup => sub {
225                 shift->(form => $form, cgi => $q, session => $session);
226         });
227         
228         $form->field(name => "do", type => "hidden");
229         $form->field(name => "email", size => 50);
230         $form->field(name => "subscriptions", size => 50,
231                 comment => "(".htmllink("", "", "PageSpec", noimageinline => 1).")");
232         $form->field(name => "banned_users", size => 50);
233         
234         my $user_name=$session->param("name");
235         if (! is_admin($user_name)) {
236                 $form->field(name => "banned_users", type => "hidden");
237         }
239         if (! $form->submitted) {
240                 $form->field(name => "email", force => 1,
241                         value => userinfo_get($user_name, "email"));
242                 $form->field(name => "subscriptions", force => 1,
243                         value => userinfo_get($user_name, "subscriptions"));
244                 if (is_admin($user_name)) {
245                         $form->field(name => "banned_users", force => 1,
246                                 value => join(" ", get_banned_users()));
247                 }
248         }
249         
250         decode_form_utf8($form);
251         
252         if ($form->submitted eq 'Logout') {
253                 $session->delete();
254                 redirect($q, $config{url});
255                 return;
256         }
257         elsif ($form->submitted eq 'Cancel') {
258                 redirect($q, $config{url});
259                 return;
260         }
261         elsif ($form->submitted eq 'Save Preferences' && $form->validate) {
262                 foreach my $field (qw(email subscriptions)) {
263                         if (defined $form->field($field) && length $form->field($field)) {
264                                 userinfo_set($user_name, $field, $form->field($field)) ||
265                                         error("failed to set $field");
266                         }
267                 }
268                 if (is_admin($user_name)) {
269                         set_banned_users(grep { ! is_admin($_) }
270                                         split(' ',
271                                                 $form->field("banned_users"))) ||
272                                 error("failed saving changes");
273                 }
274                 $form->text(gettext("Preferences saved."));
275         }
276         
277         if (exists $hooks{formbuilder}) {
278                 run_hooks(formbuilder => sub {
279                         shift->(form => $form, cgi => $q, session => $session,
280                                 buttons => $buttons);
281                 });
282         }
283         else {
284                 printheader($session);
285                 print misctemplate($form->title, $form->render(submit => $buttons));
286         }
287 } #}}}
289 sub cgi_editpage ($$) { #{{{
290         my $q=shift;
291         my $session=shift;
293         my @fields=qw(do rcsinfo subpage from page type editcontent comments);
294         my @buttons=("Save Page", "Preview", "Cancel");
295         
296         eval q{use CGI::FormBuilder};
297         error($@) if $@;
298         my $form = CGI::FormBuilder->new(
299                 fields => \@fields,
300                 header => 1,
301                 charset => "utf-8",
302                 method => 'POST',
303                 validate => {
304                         editcontent => '/.+/',
305                 },
306                 required => [qw{editcontent}],
307                 javascript => 0,
308                 params => $q,
309                 action => $config{cgiurl},
310                 table => 0,
311                 template => scalar template_params("editpage.tmpl"),
312         );
313         
314         run_hooks(formbuilder_setup => sub {
315                 shift->(form => $form, cgi => $q, session => $session);
316         });
317         
318         decode_form_utf8($form);
319         
320         # This untaint is safe because titlepage removes any problematic
321         # characters.
322         my ($page)=$form->field('page');
323         $page=titlepage(possibly_foolish_untaint($page));
324         if (! defined $page || ! length $page || file_pruned($page, $config{srcdir}) || $page=~/^\//) {
325                 error("bad page name");
326         }
327         
328         my $from;
329         if (defined $form->field('from')) {
330                 ($from)=$form->field('from')=~/$config{wiki_file_regexp}/;
331         }
332         
333         my $file;
334         my $type;
335         if (exists $pagesources{$page} && $form->field("do") ne "create") {
336                 $file=$pagesources{$page};
337                 $type=pagetype($file);
338                 if (! defined $type) {
339                         error(sprintf(gettext("%s is not an editable page"), $page));
340                 }
341                 if (! $form->submitted) {
342                         $form->field(name => "rcsinfo",
343                                 value => rcs_prepedit($file), force => 1);
344                 }
345         }
346         else {
347                 $type=$form->param('type');
348                 if (defined $type && length $type && $hooks{htmlize}{$type}) {
349                         $type=possibly_foolish_untaint($type);
350                 }
351                 elsif (defined $from) {
352                         # favor the type of linking page
353                         $type=pagetype($pagesources{$from});
354                 }
355                 $type=$config{default_pageext} unless defined $type;
356                 $file=$page.".".$type;
357                 if (! $form->submitted) {
358                         $form->field(name => "rcsinfo", value => "", force => 1);
359                 }
360         }
362         $form->field(name => "do", type => 'hidden');
363         $form->field(name => "from", type => 'hidden');
364         $form->field(name => "rcsinfo", type => 'hidden');
365         $form->field(name => "subpage", type => 'hidden');
366         $form->field(name => "page", value => pagetitle($page, 1), force => 1);
367         $form->field(name => "type", value => $type, force => 1);
368         $form->field(name => "comments", type => "text", size => 80);
369         $form->field(name => "editcontent", type => "textarea", rows => 20,
370                 cols => 80);
371         $form->tmpl_param("can_commit", $config{rcs});
372         $form->tmpl_param("indexlink", indexlink());
373         $form->tmpl_param("helponformattinglink",
374                 htmllink("", "", "HelpOnFormatting", noimageinline => 1));
375         $form->tmpl_param("baseurl", baseurl());
376         
377         if ($form->submitted eq "Cancel") {
378                 if ($form->field("do") eq "create" && defined $from) {
379                         redirect($q, "$config{url}/".htmlpage($from));
380                 }
381                 elsif ($form->field("do") eq "create") {
382                         redirect($q, $config{url});
383                 }
384                 else {
385                         redirect($q, "$config{url}/".htmlpage($page));
386                 }
387                 return;
388         }
389         elsif ($form->submitted eq "Preview") {
390                 $form->tmpl_param("page_preview",
391                         htmlize($page, $type,
392                         linkify($page, "",
393                         preprocess($page, $page,
394                         filter($page, $form->field('editcontent')), 0, 1))));
395         }
396         else {
397                 $form->tmpl_param("page_preview", "");
398         }
399         $form->tmpl_param("page_conflict", "");
400         
401         if (! $form->submitted || $form->submitted eq "Preview" || 
402             ! $form->validate) {
403                 if ($form->field("do") eq "create") {
404                         my @page_locs;
405                         my $best_loc;
406                         if (! defined $from || ! length $from ||
407                             $from ne $form->field('from') ||
408                             file_pruned($from, $config{srcdir}) ||
409                             $from=~/^\// ||
410                             $form->submitted eq "Preview") {
411                                 @page_locs=$best_loc=$page;
412                         }
413                         else {
414                                 my $dir=$from."/";
415                                 $dir=~s![^/]+/+$!!;
416                                 
417                                 if ((defined $form->field('subpage') && length $form->field('subpage')) ||
418                                     $page eq gettext('discussion')) {
419                                         $best_loc="$from/$page";
420                                 }
421                                 else {
422                                         $best_loc=$dir.$page;
423                                 }
424                                 
425                                 push @page_locs, $dir.$page;
426                                 push @page_locs, "$from/$page";
427                                 while (length $dir) {
428                                         $dir=~s![^/]+/+$!!;
429                                         push @page_locs, $dir.$page;
430                                 }
431                         }
432                         push @page_locs, "$config{userdir}/$page"
433                                 if length $config{userdir};
435                         @page_locs = grep {
436                                 ! exists $pagecase{lc $_}
437                         } @page_locs;
438                         if (! @page_locs) {
439                                 # hmm, someone else made the page in the
440                                 # meantime?
441                                 redirect($q, "$config{url}/".htmlpage($page));
442                                 return;
443                         }
445                         my @editable_locs = grep {
446                                 check_canedit($_, $q, $session, 1)
447                         } @page_locs;
448                         if (! @editable_locs) {
449                                 # let it throw an error this time
450                                 map { check_canedit($_, $q, $session) } @page_locs;
451                         }
452                         
453                         my @page_types;
454                         if (exists $hooks{htmlize}) {
455                                 @page_types=keys %{$hooks{htmlize}};
456                         }
457                         
458                         $form->tmpl_param("page_select", 1);
459                         $form->field(name => "page", type => 'select',
460                                 options => [ map { pagetitle($_, 1) } @editable_locs ],
461                                 value => pagetitle($best_loc, 1));
462                         $form->field(name => "type", type => 'select',
463                                 options => \@page_types);
464                         $form->title(sprintf(gettext("creating %s"), pagetitle($page)));
465                 }
466                 elsif ($form->field("do") eq "edit") {
467                         check_canedit($page, $q, $session);
468                         if (! defined $form->field('editcontent') || 
469                             ! length $form->field('editcontent')) {
470                                 my $content="";
471                                 if (exists $pagesources{$page}) {
472                                         $content=readfile(srcfile($pagesources{$page}));
473                                         $content=~s/\n/\r\n/g;
474                                 }
475                                 $form->field(name => "editcontent", value => $content,
476                                         force => 1);
477                         }
478                         $form->tmpl_param("page_select", 0);
479                         $form->field(name => "page", type => 'hidden');
480                         $form->field(name => "type", type => 'hidden');
481                         $form->title(sprintf(gettext("editing %s"), pagetitle($page)));
482                 }
483                 
484                 print $form->render(submit => \@buttons);
485         }
486         else {
487                 # save page
488                 check_canedit($page, $q, $session);
489                 if (! -e "$config{srcdir}/$file" &&
490                     $form->field("do") ne "create") {
491                         $form->tmpl_param("page_gone", 1);
492                         $form->field(name => "do", value => "create", force => 1);
493                         $form->tmpl_param("page_select", 0);
494                         $form->field(name => "page", type => 'hidden');
495                         $form->field(name => "type", type => 'hidden');
496                         $form->title(sprintf(gettext("editing %s"), $page));
497                         print $form->render(submit => \@buttons);
498                         return;
499                 }
500                 elsif (-e "$config{srcdir}/$file" &&
501                        $form->field("do") eq "create") {
502                         $form->tmpl_param("creation_conflict", 1);
503                         $form->field(name => "do", value => "edit", force => 1);
504                         $form->tmpl_param("page_select", 0);
505                         $form->field(name => "page", type => 'hidden');
506                         $form->field(name => "type", type => 'hidden');
507                         $form->title(sprintf(gettext("editing %s"), $page));
508                         $form->field("editcontent", 
509                                 value => readfile("$config{srcdir}/$file").
510                                          "\n\n\n".$form->field("editcontent"),
511                                 force => 1);
512                         print $form->render(submit => \@buttons);
513                         return;
514                 }
515                 
516                 my $content=$form->field('editcontent');
518                 $content=~s/\r\n/\n/g;
519                 $content=~s/\r/\n/g;
521                 $config{cgi}=0; # avoid cgi error message
522                 eval { writefile($file, $config{srcdir}, $content) };
523                 $config{cgi}=1;
524                 if ($@) {
525                         $form->field(name => "rcsinfo", value => rcs_prepedit($file),
526                                 force => 1);
527                         $form->tmpl_param("failed_save", 1);
528                         $form->tmpl_param("error_message", $@);
529                         $form->field("editcontent", value => $content, force => 1);
530                         $form->tmpl_param("page_select", 0);
531                         $form->field(name => "page", type => 'hidden');
532                         $form->field(name => "type", type => 'hidden');
533                         $form->title(sprintf(gettext("editing %s"), $page));
534                         print $form->render(submit => \@buttons);
535                         return;
536                 }
537                 
538                 my $conflict;
539                 if ($config{rcs}) {
540                         my $message="";
541                         if (defined $form->field('comments') &&
542                             length $form->field('comments')) {
543                                 $message=$form->field('comments');
544                         }
545                         
546                         if ($form->field("do") eq "create") {
547                                 rcs_add($file);
548                         }
550                         # Prevent deadlock with post-commit hook by
551                         # signaling to it that it should not try to
552                         # do anything (except send commit mails).
553                         disable_commit_hook();
554                         $conflict=rcs_commit($file, $message,
555                                 $form->field("rcsinfo"),
556                                 $session->param("name"), $ENV{REMOTE_ADDR});
557                         enable_commit_hook();
558                         rcs_update();
559                 }
560                 
561                 # Refresh even if there was a conflict, since other changes
562                 # may have been committed while the post-commit hook was
563                 # disabled.
564                 require IkiWiki::Render;
565                 refresh();
566                 saveindex();
568                 if (defined $conflict) {
569                         $form->field(name => "rcsinfo", value => rcs_prepedit($file),
570                                 force => 1);
571                         $form->tmpl_param("page_conflict", 1);
572                         $form->field("editcontent", value => $conflict, force => 1);
573                         $form->field("do", "edit", force => 1);
574                         $form->tmpl_param("page_select", 0);
575                         $form->field(name => "page", type => 'hidden');
576                         $form->field(name => "type", type => 'hidden');
577                         $form->title(sprintf(gettext("editing %s"), $page));
578                         print $form->render(submit => \@buttons);
579                         return;
580                 }
581                 else {
582                         # The trailing question mark tries to avoid broken
583                         # caches and get the most recent version of the page.
584                         redirect($q, "$config{url}/".htmlpage($page)."?updated");
585                 }
586         }
587 } #}}}
589 sub cgi_getsession ($) { #{{{
590         my $q=shift;
592         eval q{use CGI::Session};
593         CGI::Session->name("ikiwiki_session_".encode_utf8($config{wikiname}));
594         
595         my $oldmask=umask(077);
596         my $session = CGI::Session->new("driver:DB_File", $q,
597                 { FileName => "$config{wikistatedir}/sessions.db" });
598         umask($oldmask);
600         return $session;
601 } #}}}
603 sub cgi_savesession ($) { #{{{
604         my $session=shift;
606         # Force session flush with safe umask.
607         my $oldmask=umask(077);
608         $session->flush;
609         umask($oldmask);
610 } #}}}
612 sub cgi (;$$) { #{{{
613         my $q=shift;
614         my $session=shift;
616         if (! $q) {
617                 eval q{use CGI};
618                 error($@) if $@;
619         
620                 $q=CGI->new;
621         
622                 run_hooks(cgi => sub { shift->($q) });
623         }
625         my $do=$q->param('do');
626         if (! defined $do || ! length $do) {
627                 my $error = $q->cgi_error;
628                 if ($error) {
629                         error("Request not processed: $error");
630                 }
631                 else {
632                         error("\"do\" parameter missing");
633                 }
634         }
635         
636         # Things that do not need a session.
637         if ($do eq 'recentchanges') {
638                 cgi_recentchanges($q);
639                 return;
640         }
641         elsif ($do eq 'hyperestraier') {
642                 cgi_hyperestraier();
643         }
645         # Need to lock the wiki before getting a session.
646         lockwiki();
647         
648         if (! $session) {
649                 $session=cgi_getsession($q);
650         }
651         
652         # Auth hooks can sign a user in.
653         if ($do ne 'signin' && ! defined $session->param("name")) {
654                 run_hooks(auth => sub {
655                         shift->($q, $session)
656                 });
657                 if (defined $session->param("name")) {
658                         # Make sure whatever user was authed is in the
659                         # userinfo db.
660                         if (! userinfo_get($session->param("name"), "regdate")) {
661                                 userinfo_setall($session->param("name"), {
662                                         email => "",
663                                         password => "",
664                                         regdate => time,
665                                 }) || error("failed adding user");
666                         }
667                 }
668         }
669         
670         if (defined $session->param("name") &&
671             userinfo_get($session->param("name"), "banned")) {
672                 print $q->header(-status => "403 Forbidden");
673                 $session->delete();
674                 print gettext("You are banned.");
675                 cgi_savesession($session);
676         }
677         elsif ($do eq 'signin') {
678                 cgi_signin($q, $session);
679                 cgi_savesession($session);
680         }
681         elsif (defined $session->param("postsignin")) {
682                 cgi_postsignin($q, $session);
683         }
684         elsif ($do eq 'prefs') {
685                 cgi_prefs($q, $session);
686         }
687         elsif ($do eq 'create' || $do eq 'edit') {
688                 cgi_editpage($q, $session);
689         }
690         elsif ($do eq 'blog') {
691                 my $page=decode_utf8($q->param('title'));
692                 $page=~s/\///g; # no slashes in blog posts
693                 # if the page already exists, munge it to be unique
694                 my $from=$q->param('from');
695                 my $add="";
696                 while (exists $pagecase{lc($from."/".titlepage($page).$add)}) {
697                         $add=1 unless length $add;
698                         $add++;
699                 }
700                 $q->param('page', $page.$add);
701                 # now run same as create
702                 $q->param('do', 'create');
703                 cgi_editpage($q, $session);
704         }
705         elsif ($do eq 'postsignin') {
706                 error(gettext("login failed, perhaps you need to turn on cookies?"));
707         }
708         else {
709                 error("unknown do parameter");
710         }
711 } #}}}
713 sub userlink ($) { #{{{
714         my $user=shift;
716         eval q{use CGI 'escapeHTML'};
717         error($@) if $@;
718         if ($user =~ m!^https?://! &&
719             eval q{use Net::OpenID::VerifiedIdentity; 1} && !$@) {
720                 # Munge user-urls, as used by eg, OpenID.
721                 my $oid=Net::OpenID::VerifiedIdentity->new(identity => $user);
722                 my $display=$oid->display;
723                 # Convert "user.somehost.com" to "user [somehost.com]".
724                 if ($display !~ /\[/) {
725                         $display=~s/^(.*?)\.([^.]+\.[a-z]+)$/$1 [$2]/;
726                 }
727                 # Convert "http://somehost.com/user" to "user [somehost.com]".
728                 if ($display !~ /\[/) {
729                         $display=~s/^https?:\/\/(.+)\/([^\/]+)$/$2 [$1]/;
730                 }
731                 $display=~s!^https?://!!; # make sure this is removed
732                 return "<a href=\"$user\">".escapeHTML($display)."</a>";
733         }
734         else {
735                 return htmllink("", "", escapeHTML(
736                         length $config{userdir} ? $config{userdir}."/".$user : $user
737                 ), noimageinline => 1);
738         }
739 } #}}}