X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=ND.pm;h=7ac8e354487e720876fad29ea593fab385090ad8;hb=2a0730763283fb04dd842b4011b15da8ee9206c7;hp=404c8795648e042764cc2c28443b56a476e85981;hpb=f9bfa2ffe57377a483158ac96a6f81156b5b9220;p=ndwebbie.git diff --git a/ND.pm b/ND.pm index 404c879..7ac8e35 100755 --- a/ND.pm +++ b/ND.pm @@ -43,6 +43,7 @@ sub handler { local $ND::BODY; local $ND::TICK; local %ND::GROUPS; + local $ND::ERROR; local $ND::PAGE = $ND::req->param('page'); if ($ENV{'SCRIPT_NAME'} =~ /(\w+)(\.(pl|php|pm))?$/){ @@ -55,7 +56,9 @@ sub handler { sub page { our $DBH = ND::DB::DB(); - my $error = ''; + $DBH->do(q{SET timezone = 'GMT'}); + + our $ERROR = ''; chdir '/var/www/ndawn/code'; @@ -100,9 +103,9 @@ sub page { } unless (my $return = do "$ND::PAGE.pl"){ - $error .= "

couldn't parse $ND::PAGE: $@

" if $@; - $error .= "

couldn't do $ND::PAGE: $!

" unless defined $return && defined $!; - $error .= "

couldn't run $ND::PAGE

" unless $return; + $ERROR .= "

couldn't parse $ND::PAGE: $@

" if $@; + $ERROR .= "

couldn't do $ND::PAGE: $!

" unless defined $return && defined $!; + $ERROR .= "

couldn't run $ND::PAGE

" unless $return; } unless ($XML){ @@ -110,6 +113,16 @@ 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 IN (SELECT fbid FROM forum_access WHERE gid IN (SELECT groups($1))) + },undef,$UID) or $ERROR .= p($DBH->errstr); + + $TEMPLATE->param(UnreadPosts => $unread); $TEMPLATE->param(Tick => $TICK); $TEMPLATE->param(isMember => (($TICK - $fleetupdate < 24) || isScanner()) && $PLANET && isMember()); $TEMPLATE->param(isHC => isHC()); @@ -123,7 +136,7 @@ sub page { $TEMPLATE->param(Coords => param('coords') ? param('coords') : '1:1:1'); } - $TEMPLATE->param(Error => $error); + $TEMPLATE->param(Error => $ERROR); $ND::TEMPLATE->param(BODY => $ND::BODY->output); my $output = $TEMPLATE->output; print header(-type=> $type, -charset => 'utf-8', -Content_Length => length $output);