% if ($rss_link) { Comics Page
% for (@comics) { <& 'm/display', $_ &> % } % if (!$ARGS{all}) { <& 'news.html' &> % } % if (@also) {
Also available but not shown: <% join(', ', map { qq($c{$_}) } @also) %>.


% }
Logged in as <% $user %>: Edit Comics, Edit Account, or Log Out    % if ($ARGS{all}) { View Your Comics % } else { View All Current % }  /  View Older  /  RSS Links

% } elsif ($opml) { <% $user |h %>'s comics % for my $n (@comics) { % } % } else { <% $user |h %>'s comics http://bushong.net/comics/ custom comics for <% $user |h %> <% strftime('%a, %d %b %Y %T %z', localtime) %> % for (@comics) { <& m/display, $_, 1 &> % } % } <%args> $chk => undef $user => undef $opml => 0 <%init> my ($rss_link, @comics, @also); if ($user && $chk) { if ($chk ne $m->comp('m/chk', $user)) { $r->status(403); $m->print("user $user does not match chk $chk\n"); return; } $r->content_type('application/xml'); } else { $user = $m->comp('m/get_user'); $rss_link = "http://bushong.net/comics/?user=$user&chk=" . $m->comp('m/chk', $user); } my %c = $m->comp('m/get_comics'); if ($ARGS{all}) { @comics = sort { lc($c{$a}) cmp lc($c{$b}) } keys(%c); } else { $m->comp('/m/redirect', 'login.html') unless defined $user; my $dbh = $m->comp('m/connect'); my $sth = $dbh->prepare('select comics from user where user = ?'); $sth->execute($user); @comics = split(/,/, ($sth->fetchrow_array)[0]); $sth->finish; my @real = grep { $c{$_} } @comics; for my $k (keys %c) { $c{$k} =~ s/&/&/g; $c{$k} =~ s//>/g; push(@also, $k) unless grep { $k eq $_ } @real; } @also = sort { lc($c{$a}) cmp lc($c{$b}) } @also; if (@real != @comics) { $dbh->do(sprintf( 'update user set comics = %s where user = %s', $dbh->quote(join(',', @real)), $dbh->quote($user))); @comics = @real; } $dbh->disconnect; $m->comp('/m/redirect', 'edit_comics.html') unless @comics; }