X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=ND.pm;h=8b2fdb3d9b2e872213e899edf86c686a1fa490c2;hb=8551be2ae42a4a4e7a425e2a71ead79c10bf9df4;hp=dd017f3a4201c73c8a579373ace4d9446e0d1eb1;hpb=9ce5a8529e75cb109ed9ba3fc788c94ef47b1080;p=ndwebbie.git diff --git a/ND.pm b/ND.pm index dd017f3..8b2fdb3 100755 --- a/ND.pm +++ b/ND.pm @@ -26,6 +26,7 @@ use DBD::Pg qw(:pg_types); use Apache2::Request; use ND::Web::Include; use ND::DB; +use ND::Include; use Tie::File; use Fcntl 'O_RDONLY'; use strict; @@ -52,7 +53,7 @@ sub handler { if ($ENV{'SCRIPT_NAME'} =~ /(\w+)(\.(pl|php|pm))?$/){ $ND::PAGE = $1 unless $1 eq 'index' and $3 eq 'pl'; } - $ND::PAGE = 'main' unless exists $PAGES{$ND::PAGE}; + $ND::PAGE = 'main' unless (defined $ND::PAGE and exists $PAGES{$ND::PAGE}); $PAGES{$ND::PAGE}->{parse}->($ENV{REQUEST_URI}); @@ -110,15 +111,8 @@ sub page { $fleetupdate = 0 unless defined $fleetupdate; - my ($unread) = $DBH->selectrow_array(q{ - SELECT count(*) AS unread -FROM forum_boards fb NATURAL JOIN forum_threads ft - JOIN forum_posts fp USING (ftid) LEFT OUTER JOIN - (SELECT * FROM forum_thread_visits WHERE uid = $1) ftv ON ftv.ftid = ft.ftid -WHERE (ftv.time IS NULL OR fp.time > ftv.time) AND fbid > 0 AND - fbid IN (SELECT fbid FROM forum_access WHERE gid IN (SELECT groups($1))) - },undef,$UID) or $ERROR .= p($DBH->errstr); - + my ($unread,$lastv) = $DBH->selectrow_array(unread_query,undef,$UID) or $ERROR .= p($DBH->errstr); + $TEMPLATE->param(UnreadPosts => $unread); $TEMPLATE->param(Tick => $TICK); $TEMPLATE->param(isMember => (($TICK - $fleetupdate < 24) || isScanner()) && $PLANET && isMember()); @@ -131,6 +125,8 @@ WHERE (ftv.time IS NULL OR fp.time > ftv.time) AND fbid > 0 AND $ND::TEMPLATE->param(Targets => listTargets()); } $TEMPLATE->param(Coords => param('coords') ? param('coords') : '1:1:1'); + my ($css) = $DBH->selectrow_array(q{SELECT css FROM users WHERE uid = $1},undef,$ND::UID); + $TEMPLATE->param(CSS => $css); } $TEMPLATE->param(Error => $ERROR);