%# -*-perl-*- $Id: showthread.html,v 1.3 2000/10/29 21:32:49 xi Exp $ <%doc> ############################################################################### # Usenet Indexer - A nice and fast usenet indexer # Copyright (C) 2000 Christian Laursen # # 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 ############################################################################### <% $r->hostname %> %show_hier($top); <%args> $id => '' <%init> chdir ("/home/xi/projects/deja.borderworlds.dk/docs"); if ($id !~ /^\d+$/) { $m->out("You bastard!"); $m->abort(200); } # Find the top article my $top = $id; while (my $parent = parent($top)) { $top = $parent; } <%once> sub show_hier { $m->out("\n"); } sub get_headers ($) { my ($id) = @_; my ($from,$subject); local *FILE; my $file = sprintf("../data/article/%08x.headers", $id); open (FILE, "<$file") or die "Couldn't read file: $!"; while () { if (m/^From: (.*)$/) { $from = $1; } elsif (m/^Subject: (.*)$/) { $subject = $1; } } close FILE; return ($from, $subject); } sub parent ($) { my ($id) = @_; my $res = undef; local *FILE; my $file = sprintf("../data/article/%08x.headers", $id); open (FILE, "<$file") or die "Couldn't read file: $!"; while () { if (m/^Parent: (\d+)$/) { $res = $1; } } close FILE; return $res; } sub children ($) { my ($id) = @_; local *FILE; my @res = (); my $buffer; my $file = sprintf("../data/article/%08x.children", $id); if (open (FILE, "<$file")) { while (read(FILE, $buffer, 4)) { push @res, unpack("I", $buffer); } close FILE; } return @res; }