Currently viewing: <% $id %> comics back


% for (@comics) { <& m/display_old, $_, $id &> % }
Logged in as <% $user %>: Edit Comics, Edit Account, or Log Out View Current Comics % if ($id < 7) {  /  View Older % } % if ($id > 1) {  /  View Newer % }

<%args> $id <%init> my ($user, @comics, @real, $dbh, $sth, %c); die "id not a number of in bad range" unless $id =~ /^\d+$/ && $id > 0 && $id < 8; @comics = (); $user = $m->comp('m/get_user'); %c = $m->comp('m/get_comics'); if (defined $user) { $dbh = $m->comp('m/connect'); $sth = $dbh->prepare('select comics from user where user = ?'); $sth->execute($user); @comics = split(/,/, ($sth->fetchrow_array)[0]); $sth->finish; @real = grep { $c{$_} } @comics; 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; } else { $m->comp('/m/redirect', 'login.html'); }