X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=ND.pm;h=7bac9f764c9fdf145bd8e1be5d5feeb7ee01b9a8;hb=33379bf7e2909a0f46ccf771a919121e48f9ab41;hp=3c053b853e66606e9d72c3573122deab9b4bef7d;hpb=3434a018e5752f33d863d7cccd1be8ca9426e777;p=ndwebbie.git diff --git a/ND.pm b/ND.pm index 3c053b8..7bac9f7 100755 --- a/ND.pm +++ b/ND.pm @@ -26,10 +26,13 @@ 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; -use warnings FATAL => 'all'; +use warnings; + +$SIG{__WARN__} = sub {$ND::ERROR .= p $_[0]}; chdir '/var/www/ndawn/code'; our %PAGES; @@ -100,7 +103,7 @@ sub page { $ND::BODY = HTML::Template->new(filename => "templates/$ND::PAGE.xml.tmpl", cache => 1); }else{ $ND::BODY = HTML::Template->new(filename => "templates/$ND::PAGE.tmpl", global_vars => 1, cache => 1); - $ND::BODY->param(PAGE => '/'.$ND::PAGE); + $ND::BODY->param(PAGE => $ND::PAGE); } $ND::BODY = $PAGES{$PAGE}->{render}->($DBH,$ND::BODY); @@ -110,16 +113,13 @@ 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 ($last_forum_visit) = $DBH->selectrow_array(q{SELECT last_forum_visit FROM users WHERE uid = $1} + ,undef,$UID) or $ERROR .= p($DBH->errstr); + my ($unread,$newposts) = $DBH->selectrow_array(unread_query,undef,$UID,$last_forum_visit) + or $ERROR .= p($DBH->errstr); + $TEMPLATE->param(UnreadPosts => $unread); + $TEMPLATE->param(NewPosts => $newposts); $TEMPLATE->param(Tick => $TICK); $TEMPLATE->param(isMember => (($TICK - $fleetupdate < 24) || isScanner()) && $PLANET && isMember()); $TEMPLATE->param(isHC => isHC()); @@ -131,6 +131,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);