| Server IP : 208.122.213.31 / Your IP : 216.73.216.185 Web Server : Apache System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64 User : WHMCS_MIA_382 ( 1001) PHP Version : 7.4.33 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/httpd/html/bukkake-mpegs.com/cgi-bin/tgps/ |
Upload File : |
#!/usr/bin/perl
##############################
## AutoGallery Pro v3.0.x ##
######################################################
## scanner.cgi - Gallery scanner ##
######################################################
my $CDIR = '/usr/home/explorexxx/domains/bukkake-mpegs.com/cgi-bin/tgps';
chdir($CDIR) || die "Could not change into $CDIR";
## Initialize variables
my $config = $ARGV[0];
my $start_time = undef;
my $stop_time = undef;
my $row = undef;
my $results = undef;
my $current_db = undef;
my $account = {};
my $category = {};
my $examined = 0;
my $total = 0;
my $make_report = 1;
my $t_blacklist = 0;
my $t_exception = 0;
my $t_delete = 0;
my $t_pending = 0;
my @dbs = ();
## Never check content size
$O_CHECK_SIZE = 0;
## Exception bitmasks
my %exception = (
'connection' => 0x00000001,
'status' => 0x00000002,
'blacklisted' => 0x00000004,
'banned_html' => 0x00000008,
'no_recip' => 0x00000010,
'thumb_change' => 0x00000020,
'links' => 0x00000040,
'size' => 0x00000080
);
## Include the necessary helper scripts
require 'common.pl';
require 'agp.pl';
require 'http.pl';
require 'image.pl';
## See if there is an instance of this running already
if( -e "$DDIR/scanner/$config.pid" )
{
kill(9, FileReadLine("$DDIR/scanner/$config.pid"));
}
## Create the new pid file
FileWrite("$DDIR/scanner/$config.pid", $$);
## Load the configuration file
require "$DDIR/scanner/$config";
## Close us off to the outside world
close STDIN;
close STDOUT;
close STDERR;
## Catch signals
$SIG{'INT'} = \&HandleSignal;
$SIG{'HUP'} = \&HandleSignal;
## Get details on the categories
LoadCategories($category);
## Put the header on the report file
ReportHeader() if( $make_report );
## Do not check content size
$O_CHECK_SIZE = 0;
## Select the galleries to be scanned
@dbs = SelectDatabases();
$start_time = time;
for( @dbs )
{
$current_db = $_;
$total += DBSize("$DDIR/dbs/$current_db");
## Scan each gallery
for( @{FileReadArray("$DDIR/dbs/$current_db")} )
{
## Local loop variables
my $line = $_;
my $isblisted = undef;
my $iswlisted = undef;
my $removed = undef;
my $updated = undef;
my $status = 0x00000000;
chomp($line);
@$row{@{$DB_FORMAT{$current_db}}} = split(/\|/, $line);
my $cat_name = ($which_galleries eq 'permanent' ? 'Permanent' : $row->{'Category'});
my $image_id = ($which_galleries eq 'permanent' ? "p$row->{'Permanent_ID'}" : $row->{'Gallery_ID'});
## Update the number of examined galleries
$examined++;
## See if we should stop
if( -e "$DDIR/scanner/$config.sto" )
{
last;
}
## Make sure another instance hasn't taken over
if( $$ != FileReadLine("$DDIR/scanner/$config.pid") )
{
exit;
}
## Update status
FileWrite("$DDIR/scanner/$config.sta", time . "|$examined|$total");
## Setup trusted partner account information
$account = {};
if( $which_galleries ne 'permanent' && $row->{'Account_ID'} )
{
$account = DBSelect("$DDIR/dbs/accounts", $row->{'Account_ID'});
}
## Set the gallery ID if we are scanning permanent galleries
if( $which_galleries eq 'permanent' )
{
$row->{'Gallery_ID'} = $row->{'Permanent_ID'};
}
## See if the gallery is whitelisted
$iswlisted = ($which_galleries eq 'permanent' ? 1 : IsWhitelisted($row->{'Gallery_URL'}));
## Scan the gallery
$results = ScanGallery($row->{'Gallery_URL'}, $category->{$cat_name}, $account, $iswlisted);
## Broken gallery URL
if( $results->{'Errstr'} )
{
## Bad status code
if( $results->{'Status'} )
{
ProcessGallery($row, $results, $exception{'status'});
}
## Connection error
else
{
ProcessGallery($row, $results, $exception{'connection'});
}
next;
}
if( $which_galleries ne 'permanent' )
{
## Check the blacklist
if( !$iswlisted && $blacklisted )
{
$isblisted = IsBlacklisted($row);
}
if( $isblisted && (!$account->{'Account_ID'} || !$account->{'Blacklist'}) )
{
$results->{'Blacklist_Item'} = $isblisted->{'Item'};
$status |= $exception{'blacklisted'};
}
## Check for banned HTML
if( $results->{'Has_Banned'} && (!$account->{'Account_ID'} || !$account->{'HTML'}) )
{
$status |= $exception{'banned_html'};
}
## Check reciprocal link
if( !$results->{'Has_Recip'} && (!$account->{'Account_ID'} || $account->{'Recip'}) )
{
$status |= $exception{'no_recip'};
}
## See if thumb count has changed
if( $results->{'Thumbnails'} != $row->{'Thumbnails'} )
{
if( $results->{'Thumbnails'} > 0 )
{
$row->{'Thumbnails'} = $results->{'Thumbnails'};
$updated = 1;
}
## If the thumbnail count was zero, do not flag as a bad gallery.
## This almost certainly means the gallery was imported without a
## thumbnail count
if( $row->{'Thumbnails'} != 0 )
{
$status |= $exception{'thumb_change'};
}
}
## Check the number of external links
if( $results->{'Links'} > $LINKS )
{
$status |= $exception{'links'};
}
## Update the gallery IP
if( !$row->{'Gallery_IP'} )
{
$updated = 1;
$row->{'Gallery_IP'} = $results->{'Gallery_IP'};
}
}
## Generate preview thumbnail
if( $create_thumbs && (!-e "$THUMB_DIR/$image_id.jpg") && $results->{'Preview'} )
{
my $req = new HTTP(URL=>$results->{'Preview'}, Referrer=>$row->{'Gallery_URL'});
if( $req->GET() )
{
AutoResize(\$req->{'Data'}, $image_id, $row->{'Category'});
}
if( $which_galleries eq 'permanent' )
{
$row->{'Thumbnail_URL'} = "$THUMB_URL/$image_id.jpg";
$updated = 1;
}
}
## Mark as scanned
if( !$row->{'Scanned'} )
{
$updated = 1;
$row->{'Scanned'} = 1;
}
## Update database information
if( $updated )
{
DBUpdate("$DDIR/dbs/$current_db", $row->{'Gallery_ID'}, $row);
}
if( $status )
{
ProcessGallery($row, $results, $status);
}
}
}
$stop_time = time;
#cashguy Thu Sep 9 12:01:48 2004 69.196.139.17
## Put the footer on the report file
ReportFooter() if( $make_report );
## Update TGP Pages
BuildAllPages() if( $update_pages );
## Send e-mail
SendCompleteEmail() if( $send_email );
sleep(10);
## Remove the PID and status files
FileRemove("$DDIR/scanner/$config.pid");
FileRemove("$DDIR/scanner/$config.sta") if( -e "$DDIR/scanner/$config.sta" );
FileRemove("$DDIR/scanner/$config.sto") if( -e "$DDIR/scanner/$config.sto" );
########################################################################################################
########################################################################################################
########################################################################################################
sub SendCompleteEmail
{
my $message = "=>[Subject]\n" .
"AutoGallery Pro Scanner Completed\n" .
"=>[Text]\n" .
"The AutoGallery Pro gallery scanner has completed it's task.\n" .
"$examined of $total galleries were examined.\n" .
"A report has been generated for you to view.\n" .
"$MAIN_URL/report-$config.html\n";
$T{'To'} = $ADMIN_EMAIL;
$T{'From'} = $ADMIN_EMAIL;
Mail(\$message);
}
sub HandleSignal
{
my $signal = shift;
$stop_time = time;
$T{'Signal'} = "Exited on SIG$signal<br />";
ReportFooter() if( $make_report );
## Send e-mail
SendCompleteEmail() if( $send_email );
FileRemove("$DDIR/scanner/$config.pid");
FileRemove("$DDIR/scanner/$config.sta") if( -e "$DDIR/scanner/$config.sta" );
FileRemove("$DDIR/scanner/$config.sto") if( -e "$DDIR/scanner/$config.sto" );
exit;
}
sub ProcessGallery
{
my $gallery = shift;
my $results = shift;
my $status = shift;
my $reason = undef;
my $removed = undef;
my $penalty = 0x00000000;
my %reasons = (
'connection' => "Connection Error: $results->{'Errstr'}",
'status' => $results->{'Status'},
'blacklisted' => "Blacklisted Data: $results->{'Blacklist_Item'}",
'banned_html' => 'Blacklisted HTML',
'no_recip' => 'No Reciprocal Link',
'thumb_change' => 'Thumbnail Count Changed',
'links' => 'Too Many Links',
'size' => 'Gallery Content Size'
);
for( keys %exception )
{
if( $status & $exception{$_} && ${$_} >= $penalty )
{
$reason = $reasons{$_};
$penalty = ${$_};
}
}
## Blacklist
if( $penalty & 0x00000008 )
{
$t_blacklist++;
$t_exception++;
$status = 'Blacklisted';
$removed = 1;
RemoveGallery($gallery);
if( $which_galleries ne 'permanent' )
{
AddBlacklist('domain', LevelUpURL($gallery->{'Gallery_URL'}));
AddBlacklist('email', $gallery->{'Email'});
AddBlacklist('submitip', $gallery->{'Submit_IP'});
}
}
## Delete
elsif( $penalty & 0x00000004 )
{
$t_delete++;
$t_exception++;
$removed = 1;
$status = '<font color="red">Deleted</font>';
RemoveGallery($gallery);
}
## Pending
elsif( $penalty & 0x00000002 )
{
$t_pending++;
$t_exception++;
$status = '<font color="blue">Pending</font>';
## Move gallery to pending database
if( $which_galleries ne 'permanent' )
{
$gallery = DBDelete("$DDIR/dbs/$current_db", $gallery->{'Gallery_ID'});
DBInsert("$DDIR/dbs/pending", $gallery);
}
}
## Display in report
elsif( $penalty & 0x00000001 )
{
$t_exception++;
$status = '<font color="Green">Unchanged</font>';
}
## Ignore
else
{
return $removed;
}
UpdateReport($gallery, $status, $reason) if( $make_report );
return $removed;
}
sub RemoveGallery
{
my $gallery = shift;
my $image_id = ($which_galleries eq 'permanent' ? "p$gallery->{'Permanent_ID'}" : $gallery->{'Gallery_ID'});
DBDelete("$DDIR/dbs/$current_db", $gallery->{'Gallery_ID'});
if( -e "$THUMB_DIR/$image_id.jpg" )
{
unlink("$THUMB_DIR/$image_id.jpg");
}
}
sub AddBlacklist
{
my $type = shift;
my $item = lc(shift);
return if( $item =~ /^\s*$/ );
sopen(DB, "+<$DDIR/blacklist/$type");
flock(DB, LOCK_EX);
for( <DB> )
{
if( $_ eq "$item\n" )
{
flock(DB, LOCK_UN);
close(DB);
return;
}
}
print DB "$item\n";
flock(DB, LOCK_UN);
close(DB);
}
sub UpdateReport
{
my $gallery = shift;
my $status = shift;
my $reason = shift;
my $row = <<'HTML';
<tr>
<td width="75" valign="top">
<div class="padded" style="font-weight: bold;">
##Gallery_ID##
</div>
</td>
<td width="100" valign="top">
<div class="padded" style="font-weight: bold;">
##Status##
</div>
</td>
<td>
<div class="padded">
<a href="##Gallery_URL##" class="link" target="_blank">##Gallery_URL##</a><br />
##Reason##
</td>
<td width="135" valign="top">
<div class="padded" style="visibility: ##Visibility##;">
<a href="" onClick="return deleteGallery('##Gallery_ID##', '##Database##', ##Permanent##);" class="link">[Delete]</a>
<a href="" onClick="return quickBan('##Gallery_ID##', '##Database##', ##Permanent##);" class="link">[Blacklist]</a>
</td>
</tr>
<tr>
<td colspan="4" class="line"></td>
</tr>
HTML
$T{'Database'} = $current_db;
$T{'Gallery_ID'} = $gallery->{'Gallery_ID'};
$T{'Gallery_URL'} = $gallery->{'Gallery_URL'};
$T{'Status'} = $status;
$T{'Reason'} = $reason;
$T{'Visibility'} = $status =~ /Unchanged|Pending/ ? 'visible' : 'hidden';
$T{'Permanent'} = ($which_galleries eq 'permanent' ? 1 : 0);
StringParseRet(\$row);
FileAppend("$MAIN_DIR/report-$config.html", $row);
}
sub ReportHeader
{
my $head = <<'HTML';
<html>
<head>
<style>
td{font-family: Verdana; font-size: 11px;}
.padded{margin-top: 5px; margin-left: 5px; margin-bottom: 5px;}
.link{text-decoration: none; color: DarkBlue;}
.link:hover{text-decoration: none; color: Red;}
.line{height: 1px; background-color: #dcdcdc;}
.big{font-family: Arial; font-size: 16px;}
body{font-family: Arial;}
</style>
<script language="JavaScript">
function deleteGallery(id, database, perm)
{
var url = null;
if( perm )
{
url = "##Script_URL##/admin/main.cgi?Database="+database+"&Run=DeletePermanent&Permanent_ID=" + id;
}
else
{
url = "##Script_URL##/admin/main.cgi?Database="+database+"&Run=DeleteGallery&Gallery_ID=" + id;
}
if( !confirm('Are you sure you want to delete this gallery?') )
{
return false;
}
window.open(url, '_blank', 'menubar=no,height=100,width=350,scrollbars=yes,top=300,left=300');
return false;
}
function quickBan(id, database, perm)
{
if( perm )
{
alert("This feature is not available for permanent galleries");
}
else
{
var url = "##Script_URL##/admin/main.cgi?Database="+database+"&Run=DisplayQuickBan&Gallery_ID=" + id;
window.open(url, '_blank', 'menubar=no,height=225,width=650,scrollbars=yes,top=300,left=300');
}
return false;
}
</script>
</head>
<body bgcolor="#ececec">
<div align="center">
<h3>Report For ##Date##<br />##Time##</h3>
<table bgcolor="#ffffff" width="80%" cellpadding="0" cellspacing="0" style="border: 1px solid black;">
HTML
$T{'Script_URL'} = $CGI_URL;
$T{'Date'} = Date('%M %d, %Y', '%q');
$T{'Time'} = Date('%q', '%h:%i:%s %p');
StringParseRet(\$head);
FileWrite("$MAIN_DIR/report-$config.html", $head);
}
sub ReportFooter
{
my $foot = <<'HTML';
</table>
<h4>
##Signal##
##Examined## of ##Total## Galleries Examined<br />
##Run_Time##
</h4>
<table width="200">
<tr>
<td class="big">
<b>Exceptions</b>
</td>
<td class="big">
##Exception##
</td>
</tr>
<tr>
<td class="big">
<b>Pending</b>
</td>
<td class="big">
##Pending##
</td>
</tr>
<tr>
<td class="big">
<b>Deleted</b>
</td>
<td class="big">
##Deleted##
</td>
</tr>
<tr>
<td class="big">
<b>Blacklisted</b>
</td>
<td class="big">
##Blacklisted##
</td>
</tr>
</table>
</div>
</body>
</html>
HTML
$T{'Blacklisted'} = $t_blacklist;
$T{'Exception'} = $t_exception;
$T{'Deleted'} = $t_delete;
$T{'Pending'} = $t_pending;
$T{'Total'} = $total;
$T{'Examined'} = $examined;
$T{'Run_Time'} = AgeString($stop_time-$start_time);
StringParseRet(\$foot);
FileAppend("$MAIN_DIR/report-$config.html", $foot);
}
sub LoadCategories
{
my $category = shift;
if( $which_galleries eq 'permanent' )
{
$category->{'Permanent'} = {'Name'=>'Permanent', 'Type' => 'Both', 'Ext_Pictures' => 'jpg,gif,jpeg,bmp,png', 'Ext_Movies' => 'avi,mpg,mpeg,rm,wmv,mov,asf'};
}
else
{
sopen(DB, "$DDIR/dbs/categories");
for( <DB> )
{
my $row = {};
@$row{@{$DB_FORMAT{'categories'}}} = split(/\|/, $_);
$category->{$row->{'Name'}} = $row;
}
close(DB);
}
}
sub SelectDatabases
{
if( $which_galleries eq 'archived' && $ARCH_TYPE ne 'Mixed' )
{
GetCategoryList();
return map(PlainString($_), @CATEGORIES);
}
elsif( $which_galleries eq 'all' )
{
if( $ARCH_TYPE )
{
GetCategoryList();
return ('unconfirmed', 'pending', 'approved', ($ARCH_TYPE eq 'Mixed' ? 'archived' : map(PlainString($_), @CATEGORIES)));
}
else
{
return ('unconfirmed', 'pending', 'approved');
}
}
return ($which_galleries);
}