#!/usr/bin/perl -w
# an all perl much improved version of sidlist
# sts@zk65.com - http://slashtroll.tripod.com/
# This could use a lot of memory due to the hashes...
use LWP::Simple;
use CGI qw(escape);
use Getopt::Std;
use strict;
$| = 1;
my (%opts, %sids, %nicks, %hidden, $count);
getopts('vuUs', \%opts);
die_usage() unless ($opts{s} || @ARGV);
if ($opts{u}) {
while (<>) { chomp; $nicks{$_}++; }
} else {
if($opts{s}){
print "Fetching sids from comments.pl... ";
my $output = get('http://slashdot.org/comments.pl');
unless ($output) { die "Error loding comments.pl"; }
while ($output =~ /article\.pl\?sid=([^"<> ]+)/g) { $sids{$1}++; }
print "done.\n";
} else {
while (<>) { chomp; $sids{$_}++; }
}
#print "sids = ", join ':' => keys %sids, "\n";
$count = 0;
foreach my $sid (keys %sids) {
msg("Loading [%30s] - [%5d/%5d] - ",
$sid, ++$count, scalar keys %sids);
my $output = get('http://slashdot.org/comments.pl?sid=' .
escape($sid) . '&threshold=-1&mode=nested');
while($output =~ m!http://slashdot\.org/users\.pl\?
op=userinfo\&nick=([^&"<> ]+)!gx) { $nicks{$1}++; }
msg("nicks so far: %5d\r", scalar keys %nicks);
}
msg("\n");
#print "nicks = ", join ':' => keys %nicks, "\n";
}
$count = 0;
foreach my $nick (keys %nicks){
msg("Checking [%30s] - [%5d/%5d] - ",
$nick, ++$count, scalar keys %nicks);
my $output = get('http://slashdot.org/users.pl?op=userinfo&nick='.$nick);
while($output =~ /
\d+<\/B>.*?sid=([^&"<> ]+)(.*?)<\/FONT>/gs){
#print '$1 = ', $1, "\n";
#print '$2 = ', $2 =~ /attached to/ ? 'toss' : 'save', "\n";
next if $2 =~ /attached to/;
$hidden{$1}++;
}
msg("hsids so far: %5d\r", scalar keys %hidden);
}
msg("\n");
print "Writing hidden sids to 'hidden'\n";
open(OUT, ">hidden") or die;
foreach (sort keys %hidden){ print OUT "$_\n"; }
close(OUT);
if ($opts{U}) {
print "Writing users to 'users'\n";
open(OUT, ">users") or die;
foreach (sort keys %nicks) { print OUT "$_\n"; }
close(OUT);
}
print "Started with ", scalar keys %sids, " sids\n" if %sids;
print "Searched ", scalar keys(%nicks), " users\n";
print "Found ", scalar keys(%hidden), " hidden sids\n";
sub die_usage
{
print <<'EOF';
Gives a list of hidden sids by all the users posting in the sids given.
Input can either be users, sids, or a sids grabbed from comments.pl.
usage: hidden.pl [options] [files]
-v verbose
-u input is users not SIDs
-U output userlist as well
-s Read SIDs from index page
EOF
exit 1;
}
sub msg
{
printf STDERR @_ if $opts{v};
}