#!/usr/bin/perl

srand;
require "set.pl";
$username = $ENV{'QUERY_STRING'};
&printhead;
$num = "40";
open(FILE, "config.dat"); $a = @config = <FILE>; close FILE; for ($i=0; $i<$a; $i++) { chomp($config[$i]); }
$frm2 = int(rand(100)) . "f";
$frm3 = int(rand(100)) . "f";
srand;
if (int(rand(100)) <= $num) { &reguser; } else { &priorityuser; }
sub reguser {
srand;
opendir(DATA, "$config[7]");
$tot = @DB = readdir(DATA);
closedir (DATA);
$numba = int(rand($tot));
$user = "rudean";
for ($iii=0; $iii<$tot; $iii++) {
$jjj = $iii + $numba;
if ($jjj >= $tot){
$jjj = $jjj - $tot;
}
chomp($DB[$jjj]);
if ($DB[$jjj] =~ /[^a-zA-Z0-9]/) { next; }
@DBE = getfile("$config[7]/$DB[$jjj]");
if ($DBE[18] eq "yes") { next; }
if ($DBE[0] eq $username) { next; }
if ($DBE[3] - $DBE[4] < 1) { next; }
$user = $DBE[0];
@URLZ = getfile("$config[7]/$DB[$jjj].list");
chomp(@URLZ); $cnt = @URLZ;
$url = $URLZ[int(rand($cnt))];
}
}
sub priorityuser {
srand;
$tot = @DB = getfile("highpriority.txt");
$numba = int(rand($tot));
$user = "rudean";
for ($iii=0; $iii<$tot; $iii++) {
$jjj = $iii + $numba;
if ($jjj >= $tot){
$jjj = $jjj - $tot;
}
chomp($DB[$jjj]);
if ($DB[$jjj] =~ /[^a-zA-Z0-9]/) { next; }
@DBE = getfile("$config[7]/$DB[$jjj]");
if ($DBE[0] eq $username) { next; }
if ($DBE[3] - $DBE[4] <= 0) { next; }
$user = $DBE[0];
@URLZ = getfile("$config[7]/$DB[$jjj].list");
chomp(@URLZ); $cnt = @URLZ;
$url = $URLZ[int(rand($cnt))];
}if ($user eq "rudean") { &reguser; }
}

if ($user eq "rudean") { $url = $config[2]; }

print<<d00der;

<HTML>
<HEAD>
<SCRIPT>
<!--
if (top.location != self.location) {
top.location = self.location
}
-->
</SCRIPT>
<TITLE>$config[0]</TITLE>
</HEAD>
<FRAMESET ROWS="$config[5],100%" FRAMESPACING="0" BORDER="0">
<FRAME MARGINWIDTH="0" MARGINHEIGHT="0" NAME="$frm3" NORESIZE SCROLLING=NO SRC="count.cgi?u=$username&o=$user&a=bot" FRAMEBORDER="0">
<FRAME MARGINWIDTH="0" MARGINHEIGHT="0" NAME="$frm2" SCROLLING=AUTO SRC="$url" FRAMEBORDER="0">
<NOFRAMES><BODY><P></BODY></NOFRAMES></FRAMESET></HTML>
d00der
exit;
