K2LL33D SHELL

 Apache/2.4.7 (Ubuntu)
 Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64
 uid=33(www-data) gid=33(www-data) groups=33(www-data)
 safemode : OFF
 MySQL: ON | Perl: ON | cURL: OFF | WGet: ON
  >  / usr / share / doc / popularity-contest / examples /
server ip : 172.67.156.115

your ip : 108.162.241.19

H O M E


Filename/usr/share/doc/popularity-contest/examples/prepop.pl
Size1.92 kb
Permissionrwxr-xr-x
Ownerroot : root
Create time27-Apr-2025 09:55
Last modified13-May-2013 17:49
Last accessed07-Jul-2025 03:25
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
#!/usr/bin/perl -wT
# Accept popularity-contest entries on stdin and drop them into a
# subdirectory with a name based on their MD5 ID.
#
# Only the most recent entry with a given MD5 ID is kept.
#

$dirname = 'popcon-entries';
$now = time;
$state='initial'; # one of ('initial','accept','reject')

my($file,$mtime);
while(<>)
{
$state eq 'initial' and do
{
/^POPULARITY-CONTEST-0/ or next;
my @line=split(/ +/);
my %field;
for (@line)
{
my ($key, $value) = split(':', $_, 2);
$field{$key}=$value;
};
$id=$field{'ID'};
if (!defined($id) || $id !~ /^([a-f0-9]{32})$/)
{
print STDERR "Bad hostid: $id\n";
$state='reject'; next;
}
$id=$1; #untaint $id
$mtime=$field{'TIME'};
if (!defined($mtime) || $mtime!~/^([0-9]+)$/)
{
print STDERR "Bad mtime $mtime\n";
$state='reject'; next;
}
$mtime=int $1; #untaint $mtime;
$mtime=$now if ($mtime > $now);
my $dir=substr($id,0,2);
unless (-d "$dirname/$dir") {
mkdir("$dirname/$dir",0755) or do {$state='reject';next;};
};
$file="$dirname/$dir/$id";
open REPORT, ">",$file or do {$state='reject';next;};
print REPORT $_;
$state='accept'; next;
};
$state eq 'reject' and do
{
/^From/ or next;
$state='initial';next;
};
$state eq 'accept' and do
{
/^From/ and do
{
close REPORT;
unlink $file;
print STDERR "Bad report $file\n";
$state='initial';
next;
};
print REPORT $_; #accept line.
/^END-POPULARITY-CONTEST-0/ and do
{
close REPORT;
utime $mtime, $mtime, $file;
$state='initial';
next;
};
};
}
if ($state eq 'accept')
{
close REPORT;
unlink $file; #Reject
print STDERR "Bad last report $file\n";
}