#!/usr/bin/perl -w ############################################################################### # article.pl - this code displays a particular story and it's comments # # Copyright (C) 1997 Rob "CmdrTaco" Malda # malda@slashdot.org # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # # $Id: article.pl,v 1.1.1.1 2000/10/05 21:22:12 alessio Exp $ ############################################################################### use strict; use lib '../'; use vars '%I'; use vars '%L'; use Slash; ################################################################## sub main { *I = getSlashConf(); *L = \%Slash::L; getSlash(); if ($I{F}{refresh}) { sqlUpdate('stories', { writestatus => 1 }, 'sid=' . $I{dbh}->quote($I{F}{sid}) . ' and writestatus=0' ); # won't work now because HTTP headers not printed until header() below # print qq[How Refreshing! ($I{F}{sid}) \n]; } my($sect, $title, $ws); # only go to the database if we don't have it persistent in memory if ($I{storyBank}{$I{F}{sid}}) { $sect = $I{storyBank}{ $I{F}{sid} }{section}; $title = $I{storyBank}{ $I{F}{sid} }{title}; $ws = $I{storyBank}{ $I{F}{sid} }{writestatus}; } else { ($sect, $title, $ws) = sqlSelect( 'section,title,writestatus', 'stories', 'sid=' . $I{dbh}->quote($I{F}{sid}) ); } if ($ws == 10) { $ENV{SCRIPT_NAME} = ''; redirect("$I{rootdir}/$sect/$I{F}{sid}$I{userMode}.shtml"); return; }; my $SECT = getSection($sect); $title = $SECT->{isolate} ? "$SECT->{title} | $title" : "$I{sitename} | $title"; header($title, $sect); my($S, $A, $T) = displayStory($I{F}{sid}, 'Full'); print "
"; articleMenu($S, $SECT); # print qq!
\n";
$m .= <
$I{U}{mylinks} ";
fancybox($I{fancyboxwidth}, $I{U}{aid} || $I{U}{nickname}, $m);
}
##################################################################
sub articleMenu {
my($story, $SECT) = @_;
print ' < ' . nextStory('<', $story, $SECT);
my $n = nextStory('>', $story, $SECT);
print " | $n > " if $n;
print ' ';
}
##################################################################
sub nextStory {
my($sign, $story, $SECT) = @_;
my($array_place, $where);
if ($SECT->{isolate}) {
$where = 'AND section=' . $I{dbh}->quote($story->{section})
if $SECT->{isolate} == 1;
} else {
$where = 'AND displaystatus=0';
}
$where .= " AND tid not in ($I{U}{extid})" if $I{U}{extid};
$where .= " AND aid not in ($I{U}{exaid})" if $I{U}{exaid};
$where .= " AND section not in ($I{U}{exsect})" if $I{U}{exsect};
my $order = $sign eq '<' ? 'DESC' : 'ASC';
# find out what sequence this is in from the storyBank
$array_place = $I{storyBank}{$I{F}{sid}}{story_order};
# next article, previous article
$array_place += $sign eq '<' ? 1 : -1;
# if this is AC, and within the range of the number of stories in storyBank
# then get title,sid, and section from storyBank
if ( $I{sid_array}[$array_place]
&&
$I{storyBank}{$I{sid_array}[$array_place]}
&&
$I{storyBank}{$I{F}{sid}}{story_order} != ($I{StoryCount} - 1)
&&
$array_place != -1
&&
$I{U}{uid} == -1
) {
my $title = $I{storyBank}{ $I{sid_array}[$array_place] }{title};
my $psid = $I{sid_array}[$array_place];
my $section = $I{storyBank}{ $I{sid_array}[$array_place] }{section};
return linkStory({ 'link' => $title, sid => $psid, section => $section });
} elsif (my($title, $psid, $section) = sqlSelect(
'title, sid, section', 'newstories',
"time $sign '$story->{sqltime}' AND writestatus >= 0 AND time < now() $where",
"ORDER BY time $order LIMIT 1")
) {
return linkStory({ 'link' => $title, sid => $psid, section => $section });
}
'';
}
main();
$I{dbh}->disconnect if $I{dbh};
1;