#!/usr/bin/perl ############################################ ## ## ## WebAdverts (Admin) ## ## by Darryl Burgdorf ## ## (e-mail burgdorf@awsd.com) ## ## ## ## version: 3.20 ## ## last modified: 09/08/02 ## ## copyright (c) 2002 ## ## ## ## latest version is available from ## ## http://awsd.com/scripts/ ## ## ## ############################################ # Define the locations of your "ads_settings," "ads_text" # and "ads_rebuild" files. $ADVsettings_path = "/home/slowtwitch/slowtwitch.com/cgi-bin/webadverts/ads_settings.pl"; $ADVtext_path = "/home/slowtwitch/slowtwitch.com/cgi-bin/webadverts/ads_text.pl"; $ADVrebuild_path = "/home/slowtwitch/slowtwitch.com/cgi-bin/webadverts/ads_rebuild.pl"; # NOTHING BELOW THIS LINE NEEDS TO BE ALTERED! $version = "3.20"; $AdminRun = 1; $cryptword = 0; $time = time; require $ADVsettings_path; require $ADVtext_path; require $ADVdisplay_path; $_ = $UserUploadDir; /^(.+)$/; $UserUploadDir = $1; print "Content-type: text/html\n\n"; $ADVtime = time; unless ($ADVUseLocking) { &ADVMasterLockOpen; } ($SSIvirtual,$SSIfile,$PseudoQS) = (&FindSpecifics); if (($ENV{'REMOTE_ADDR'} =~ /\d+\.\d+\.\d+\.\d+/) && (!($ENV{'REMOTE_HOST'}) || ($ENV{'REMOTE_HOST'} =~ /\d+\.\d+\.\d+\.\d+/))) { @domainbytes = split(/\./,$ENV{'REMOTE_ADDR'}); $packaddr = pack("C4",@domainbytes); $resolvedip = (gethostbyaddr($packaddr, 2))[0]; unless ($resolvedip =~ /^[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,6}|[0-9]{1,3})$/) { $resolvedip = ""; } if ($resolvedip) { $ENV{'REMOTE_HOST'} = $resolvedip; } } unless ($ENV{'REMOTE_HOST'}) { $ENV{'REMOTE_HOST'} = $ENV{'REMOTE_ADDR'}; } if ($BannedIPs) { @ignoredips = split(/ /,$BannedIPs); foreach $ignoredip (@ignoredips) { if (($ENV{'REMOTE_HOST'} =~ /$ignoredip/i) || ($ENV{'REMOTE_ADDR'} =~ /$ignoredip/i)) { &Header("$text{'9000'}","$text{'9010'}"); print "
$text{'9011'}\n"; &Footer("$text{'9010'}"); } } } if ($ENV{'CONTENT_TYPE'} =~ /^multipart\/form-data/) { if ($ENV{'CONTENT_TYPE'} =~ /boundary=(\"?([^\";,]+)\"?)*/) { $boundary = $1; } binmode STDIN; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @buffer = split(/\r\n/,$buffer); foreach $line (@buffer) { if ($line =~ /$boundary/) { $Current = ""; next; } if ($line =~ /Content-Disposition/) { if ($line =~ /^.+name\s*=\s*"*([^\s"]+).+$/) { $Current = $1; } $INPUT{$Current} = ""; next; } if ($line =~ /Content-Type/) { if ($line =~ /gif/) { $BannerType = "GIF"; } elsif (($line =~ /jpeg/) || ($line =~ /jpg/)) { $BannerType = "JPG"; } $Current = "BannerFile"; $INPUT{'BannerFile'} = ""; next; } if (($line eq "") && ($Current ne "BannerFile")) { next; } if ($INPUT{$Current} && ($Current eq "BannerFile")) { $INPUT{$Current} .= "\r\n"; } $INPUT{$Current} .= $line; } } else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; if ($INPUT{$name}) { $INPUT{$name} = $INPUT{$name}." ".$value; } else { $INPUT{$name} = $value; } } } if ($INPUT{'rebuild'}) { require $ADVrebuild_path; &RebuildDatabase; } if ($INPUT{'check_database'}) { require $ADVrebuild_path; &CheckDatabase; } if ($ENV{'QUERY_STRING'} =~ /reginfo/i) { ®info; } elsif ($ENV{'QUERY_STRING'} =~ /admin/i) { &adminintro; } elsif ($INPUT{'getpass'}) { &GetPassword; } elsif ($INPUT{'register'}) { ®ister; } elsif ($INPUT{'expireemailupdate'}) { &ExpireEmailUpdate; } elsif ($INPUT{'emails'}) { &emailmembers; } elsif ($INPUT{'basedon'}) { &edit; } elsif ($INPUT{'edit'}) { &edit; } elsif ($INPUT{'newuserpassword'}) { &NewUserPassword; } elsif ($INPUT{'UserEdit'}) { &UserEdit; } elsif ($INPUT{'UploadBannerForm'}) { &UploadBannerForm; } elsif ($INPUT{'uploadbanner'}) { &UploadBanner; } elsif ($INPUT{'renameaccount'}) { &RenameAccount; } elsif ($INPUT{'del'}) { &del; } elsif ($INPUT{'delgroup'}) { &delgroup; } elsif ($INPUT{'newpass'}) { &newpass; } elsif ($INPUT{'resetcount'}) { &resetcount; } elsif ($INPUT{'editfinal'}) { &editfinal; } elsif ($INPUT{'delfinal'}) { &delfinal; } elsif ($INPUT{'delgroupfinal'}) { &delgroupfinal; } elsif ($INPUT{'reviewone'} eq "Define View") { if ($AdminDisplaySetup) { &defineview; } else { $INPUT{'whichtype'} = "pending established groups"; $INPUT{'whichtime'} = "active expired disabled"; $INPUT{'whichzone'} = ""; &reviewall; } } elsif ($INPUT{'reviewone'} eq "Review All Accounts") { &reviewall; } elsif ($INPUT{'reviewone'}) { &reviewone; } elsif ($INPUT{'dailystats'}) { &dailystats; } elsif ($INPUT{'monthlystats'}) { &monthlystats; } elsif ($INPUT{'masteriplog'}) { &masteriplog; } elsif ($INPUT{'iplog'}) { &iplog; } elsif ($INPUT{'logbyzone'}) { &logbyzone; } elsif ($INPUT{'cheatercheck'}) { &cheatercheck; } elsif ($INPUT{'resetadminlog'}) { &resetadminlog; } elsif ($INPUT{'adminlog'}) { &adminlog; } elsif ($INPUT{'listemail'}) { &ListEmail; } elsif ($INPUT{'expireemail'}) { &ExpireEmail; } elsif ($INPUT{'editgroupfinal'}) { &editgroupfinal; } elsif ($INPUT{'editgroup'}) { &editgroup; } else { &userintro; } sub userintro { &Header("$text{'1000'}","$text{'1001'}"); print "
$text{'1010'}\n", "
$text{'1020'}\n", "
$text{'1030'}\n", "
$text{'1040'}\n", "
Before you can do anything else, ", "you'll need to set your administrative password. ", "This will allow you to access the admin functions, ", "create and edit accounts, review statistics, etc. ", "Please enter your desired password below. ", "(Enter it twice.)\n", "
\n"; &Footer; } sub ConfirmAdminPassword { local($which_admin) = @_; if ($INPUT{'password'}) { $newpassword = crypt($INPUT{'password'}, "aa"); } else { &Header("$text{'9000'}","$text{'9020'}"); print "$text{'9021'}\n";
&Footer;
}
open (PASSWORD, "<$ADVadverts_dir/adpassword.txt");
$password = $text{'9031'}\n";
&Footer;
}
else {
&Header("$text{'9000'}","$text{'9022'}");
print " $text{'9023'}\n";
&Footer;
}
}
$cryptword = 1;
}
sub ConfirmUserPassword {
unless ($INPUT{'password'}) {
&Header("$text{'9000'}","$text{'9020'}");
print " $text{'9021'}\n";
&Footer;
}
if ($INPUT{'admincheck'}) {
&ConfirmAdminPassword(2);
}
open (DISPLAY, "<$ADVadverts_dir/$subdir/$AccountName.dat");
@lines = $text{'9041'} ";
print "$AccountName $text{'9042'}\n";
&Footer;
}
&SendMail($email,"getpass");
&Header("$text{'1000'}","$text{'1001'}");
print " $text{'1050'} $AccountName ";
print "$text{'1051'}\n";
&Footer;
}
sub defineview {
&ConfirmAdminPassword(1);
&Header("$text{'1000'}","$text{'1001'}");
unless ((-e "$ADVadverts_dir/register.txt") && (-w "$ADVadverts_dir/register.txt")) {
print " Unregistered copy. ";
print "Click here ";
print "for registration info. Select Which Accounts ",
"You Wish to View:\n",
" ";
print "Unregistered copy. ";
print "Click here ";
print "for registration info. ";
print "The Following Accounts ";
print "Have Been Established:\n";
if ($AdminDisplaySetup) {
print " ";
print "(Accounts Included: ";
print "$INPUT{'whichtime'})\n";
if ($INPUT{'whichzone'}) {
@whichzones = split(/\s+/,$INPUT{'whichzone'});
print " ";
($sec,$min,$hour,$mday,$mon,$year,
$wday,$yday,$isdst) = localtime($time+($ADVHourOffset*3600));
if ($hour < 10) { $hour = "0".$hour; }
if ($min < 10) { $min = "0".$min; }
$year += 1900;
print "(These figures are accurate as of ";
print "$hour:$min on $mday $months[$mon] $year";
if ($starttime) {
($sec,$min,$hour,$mday,$mon,$year,
$wday,$yday,$isdst) = localtime($starttime+($ADVHourOffset*3600));
if ($hour < 10) { $hour = "0".$hour; }
if ($min < 10) { $min = "0".$min; }
$year += 1900;
print ". CAUTION: You do not seem to have ",
"the Berkeley "DB_File" DBM (database) module available on your server, ",
"so WebAdverts is using an alternate module. The script will still run, but not ",
"as efficiently as it could, and in high traffic situations, you may see problems ",
"with database corruption or lost exposures. Please contact your server's administrators ",
"to see if you can get the "DB_File" module installed! CAUTION: You may see "gaps" ",
"in your rotation, where no banners are shown, since you currently have no ",
"banners "guaranteed" to always be available for display. You should ",
"always have at least one account set to never expire, with no display ratio ",
"or click-thru ratio, with a weight of 1, and with no assigned zones.";
if ($DefaultBanner) {
if ($DefaultAvailable) {
print " You've assigned a "default" banner ",
"("$DefaultBanner"), so the problem will be "hidden"; ",
"however, it's still best to make sure that you actually have banners ",
"properly available for display.";
}
else {
print " In addition, your "default" banner assignment ",
"("$DefaultBanner") is invalid, as the assignment doesn't ",
"match the name of any account in your rotation."
}
}
print " ";
print "The Following Accounts Await ";
print "Administrative Approval:";
print " ";
print "The Following Groups Have Been Defined:";
print "\n";
print " ";
print "Account Holder E-Mail Addresses:";
print "\n";
if ($mailprog) {
print " ";
$lastemail = "";
foreach $email (@sortedemails1) {
if ($lastemail) { print " You may, if you like, copy the following listing directly ";
print "into the "To:" field in your e-mail program, to e-mail ";
print "all account holders.\n ";
$lastemail = "";
foreach $email (@sortedemails2) {
if ($email eq $lastemail) { next; }
if ($lastemail) { print ", "; }
print "$email";
$lastemail = $email;
}
print "\n";
}
&LinkBack;
&Footer;
}
sub ExpireEmail {
&ConfirmAdminPassword(1);
open (LIST, "<$ADVadverts_dir/adlist.txt");
@advertlist = ";
print "Automatic E-Mail Recipients:";
print "\n";
print " E-Mail Sent\n",
" The message has been sent.\n";
&LinkBack;
&Footer;
}
sub ExpireEmailUpdate {
&ConfirmAdminPassword(1);
@recipientlist = split(/\s/,$INPUT{'emails'});
&Header("$text{'1000'}","$text{'1001'}");
print " Recipient List Updated\n",
" The following accounts will receive update notices ",
"when the "ads_expire.pl" script is run:\n ";
open (LIST, ">$ADVadverts_dir/adexpirelist.txt");
$lastrecipient = "";
foreach $recipient (sort @recipientlist) {
if ($lastrecipient) { print " $text{'9051'} ";
print ""$AccountName" $text{'9052'}\n";
&Footer;
}
open (DISPLAY, "<$ADVadverts_dir/$AccountName.grp");
@adverts = $text{'2000'} ";
print "$AccountName $text{'2001'}\n";
foreach $advert (@adverts) {
$name = $advert;
$subdir = substr($advert,0,1);
$subdir .= "/$advert";
next unless (-s "$ADVadverts_dir/$subdir/$advert.txt");
open (DISPLAY, "<$ADVadverts_dir/$subdir/$advert.dat");
@lines = $text{'2002'}",
"\n",
" $text{'9021'}\n";
&Footer;
}
$AccountName = $INPUT{'reviewone'};
&CheckName;
if ($INPUT{'admincheck'}) {
&ConfirmAdminPassword(2);
}
unless (-s "$ADVadverts_dir/$subdir/$AccountName.txt") {
&reviewgroup;
}
$name = $AccountName;
open (DISPLAY, "<$ADVadverts_dir/$subdir/$AccountName.dat");
@lines = Comments: $comments\n"; }
&LinkBack;
}
else {
print " $text{'2005'} ";
print "$name $text{'2006'}\n";
open (COUNT, "$ADVadverts_dir/adnew.txt");
@lines = $text{'2007'}";
last;
}
}
print " $text{'2120'}\n";
}
if ($displayratio || $clicksratio) {
unless ($NoBanners) {
if ($displaycount<1) { $displaycount = "0"; }
print " $text{'2121'} ";
print &commas($displaycount)," $text{'2122'}";
if ($clicksratio || $cryptword || $ShowClicksFrom) {
print "$text{'2123'} ";
print &commas($clicksfrom)," $text{'2124'}";
}
print "$text{'2125'} ";
$earnings = 0;
if ($displayratio > 0) { $earnings = int($displaycount/$displayratio); }
if ($clicksratio > 0) { $earnings += ($clicksfrom*$clicksratio); }
print "$text{'2126'} ";
print &commas($earnings)," $text{'2127'}";
if ($displayratio > 0) {
print " $text{'2128'} ";
print "$displayratio $text{'2129'}";
}
if (($displayratio > 0) && ($clicksratio > 0)) {
print "$text{'2130'}";
}
if ($clicksratio > 0) {
print " $clicksratio $text{'2131'}";
}
print "$text{'2132'}";
unless ($max == $earnings) {
print " $text{'2133'} ";
print &commas($max-$earnings);
print " $text{'2134'}";
}
print "\n";
}
print " $text{'2135'}\n";
$HTMLCode = "";
if ($ExchangeName) {
$HTMLCode = "<!-- Begin $ExchangeName Code -->\n $text{'2150'}\n";
}
print " $text{'2210'} ";
print "$AccountName $text{'2211'}:\n";
if (@lines > 21) {
foreach $key (21..@lines-1) {
if ($lines[$key] =~ /(\S+ \S+) (\S) (\d+)/) {
$zone = $1;
$type = $2;
$count = $3;
if ($type eq "E") { $exposures{$zone} += $count; }
if ($type eq "C") {
$clicks{$zone} += $count;
unless ($exposures{$zone}) { $exposures{$zone} = "0"; }
}
}
}
print " $text{'2220'} ";
print "$AccountName $text{'2221'}";
if ($ShortenedList) {
print " $text{'2230'} ";
print "$AccountName $text{'2231'}";
print ":\n";
print " $text{'2240'} ",
"$AccountName $text{'2241'}:\n",
" $text{'2242'}\n",
" $text{'2243'}: ",&commas($ExposureCount),"\n";
print " $text{'2246'}: ${AverageEntries}\n";
print " ",
"Master IP Address Report\n",
" The following report details the IP addresses which ",
"have seen or clicked on banners in the rotation ",
"in the last $MasterIPLogDays days.\n";
$NoPrintIPs = 1;
foreach $key (a..z,0..9) {
opendir (FILES,"$ADVadverts_dir/$key");
@files = readdir(FILES);
closedir (FILES);
foreach $file (@files) {
next unless (-d "$ADVadverts_dir/$key/$file");
opendir (SUBFILES,"$ADVadverts_dir/$key/$file");
@subfiles = readdir(SUBFILES);
closedir (SUBFILES);
foreach $subfile (@subfiles) {
next unless ($subfile=~/\d\d\d\d\.log/);
open (DISPLAY, "$ADVadverts_dir/$key/$file/$subfile");
&ShowIPs;
close (DISPLAY);
}
}
}
print " Total exposures logged: ",&commas($ExposureCount),"\n";
print " Average log entries per IP address: ${AverageEntries}\n";
print " The Top 50 Most Active IP Addresses:\n";
print " ",
""Cheater Check" Report\n",
" The following report lists the number of banners shown on, ",
"and the number of click-thrus from, each exchange member site ",
"which "earns" exposures. Any sites with unusually ",
"high or low click-thru ratios may be trying to "cheat" ",
"the system by artificially inflating one or the other of those ",
"counts.\n";
open (LIST, "<$ADVadverts_dir/adlist.txt");
@advertisements = "; }
else { $NotFirst=1; }
if ($text && ($texttype eq "T")) {
print "$text Destination: ";
print "$printurl\n";
}
if ($username || $email) {
if ($url) { print " "; }
print "Account Holder: ";
if ($email) {
print "";
}
if ($username) { print "$username"; }
else { print "$email"; }
if ($email) {
print "";
}
print "\n";
}
}
sub resetadminlog {
&ConfirmAdminPassword(1);
unlink "$ADVadverts_dir/adminlog.txt";
if ($AdminDisplaySetup) { &defineview; }
else {
$INPUT{'whichtype'} = "pending established groups";
$INPUT{'whichtime'} = "active expired disabled";
$INPUT{'whichzone'} = "";
&reviewall;
}
}
sub adminlog {
&ConfirmAdminPassword(1);
&Header("$text{'1000'}","$text{'1001'}");
print " ",
"Admin Accesses Report\n",
" The following report lists the IP addresses ",
"which have accessed administrative functions.\n";
print " No account "$oldname" exists!\n";
&ADVDBMClose;
&ADVLockClose (DBMLIST, "dbmlist.txt");
&Footer;
}
$AccountName = $INPUT{'newname'};
&CheckName;
$newname = $AccountName;
$newsubdir = $subdir;
if ($DBMList{$newname}) {
&Header("$text{'9000'}","Rename Error!");
print " Account name "$newname" is already in use!\n";
&ADVDBMClose;
&ADVLockClose (DBMLIST, "dbmlist.txt");
&Footer;
}
unless (-d "$ADVadverts_dir/$newsubdir") {
mkdir ("$ADVadverts_dir/$newsubdir",0777);
chmod 0777,"$ADVadverts_dir/$newsubdir";
}
opendir (FILES,"$ADVadverts_dir/$oldsubdir");
@files = readdir(FILES);
closedir (FILES);
foreach $file (@files) {
next if ($file =~ /^\./);
$_ = $file; /^(.+)$/; $file = $1;
$newfile = $file;
$newfile =~ s/$oldname/$newname/;
rename ("$ADVadverts_dir/$oldsubdir/$file","$ADVadverts_dir/$newsubdir/$newfile");
}
rmdir ("$ADVadverts_dir/$oldsubdir");
if ($UserUploadDir) {
rename ("$UserUploadDir/$oldname\.gif","$UserUploadDir/$newname\.gif");
rename ("$UserUploadDir/$oldname\.jpg","$UserUploadDir/$newname\.jpg");
&ADVLockOpen (COUNT, "$newsubdir/$newname.txt");
@lines = Account Renamed\n",
" The "$oldname" account has been renamed "$newname."\n";
&LinkBack;
&Footer;
}
sub edit {
&ConfirmAdminPassword(1);
if ($INPUT{'reviewone'} && !($INPUT{'editad'})) {
$INPUT{'editad'} = $INPUT{'reviewone'};
}
if ($INPUT{'basedon'}) {
$AccountName = $INPUT{'basedonad'};
&CheckName;
if (-s "$ADVadverts_dir/$subdir/$AccountName.txt") {
&Header("$text{'9000'}","Name Error!");
print " Account name "$AccountName" is already in use!\n";
&ADVDBMClose;
&ADVLockClose (DBMLIST, "dbmlist.txt");
&Footer;
}
$AccountName = $INPUT{'basedonsource'};
}
else { $AccountName = $INPUT{'editad'}; }
&CheckName;
if (-s "$ADVadverts_dir/$subdir/$AccountName.txt") {
open (DISPLAY, "<$ADVadverts_dir/$subdir/$AccountName.dat");
@lines = $text{'5400'}\n";
print " $text{'9051'} ";
print ""$AccountName" $text{'9052'}\n";
&Footer;
}
$lines[0] = $INPUT{'pass'};
$INPUT{'password'} = $INPUT{'pass'};
&ADVLockOpen (DISPLAY, "$subdir/$AccountName.dat","x");
seek (DISPLAY,0,0);
foreach $key (0..3) {
print DISPLAY "$lines[$key]\n";
}
truncate (DISPLAY,tell(DISPLAY));
&ADVLockClose (DISPLAY, "$AccountName.dat");
&reviewone;
}
sub UploadBannerForm {
$AccountName = $INPUT{'reviewone'};
&CheckName;
if ($UserUploadDir && (-s "$ADVadverts_dir/$subdir/$AccountName.txt")) {
open (DISPLAY, "<$ADVadverts_dir/$subdir/$AccountName.dat");
@lines = $text{'5500'}\n";
print " Either uploading of banners isn't allowed, ";
print "or the account name provided is invalid!\n";
&ADVDBMClose;
&ADVLockClose (DBMLIST, "dbmlist.txt");
&Footer;
}
}
sub UploadBanner {
$AccountName = $INPUT{'reviewone'};
&CheckName;
if (-s "$ADVadverts_dir/$subdir/$AccountName.txt") {
open (DISPLAY, "<$ADVadverts_dir/$subdir/$AccountName.dat");
@lines = $text{'9051'} ";
print ""$AccountName" $text{'9052'}\n";
&Footer;
}
if ($BannerType eq "GIF") { $bannername = "$AccountName.gif"; }
elsif ($BannerType eq "JPG") { $bannername = "$AccountName.jpg"; }
else {
&Header("$text{'9000'}","$text{'9060'}");
print " $text{'9061'}\n";
&Footer;
}
if (length($INPUT{'BannerFile'}) > ($MaxBannerSize*1024)) {
&Header("$text{'9000'}","$text{'9070'}");
print " $text{'9071'} ";
print "$MaxBannerSize $text{'9072'} ";
print int((length($INPUT{'BannerFile'})/1024)+.5)," $text{'9073'}\n";
&Footer;
}
unless (open (BANNER,">$UserUploadDir/$bannername")) {
&Header("$text{'9000'}","$text{'9080'}");
print " $text{'9081'}\n";
&Footer;
}
binmode BANNER;
print BANNER $INPUT{'BannerFile'};
close (BANNER);
$image = "$UserUploadURL/$bannername";
&ADVLockOpen (DISPLAY, "$subdir/$AccountName.txt","x");
seek (DISPLAY,0,0);
$lines[4] = $image;
foreach $key (0..20) {
print DISPLAY "$lines[$key]\n";
}
truncate (DISPLAY,tell(DISPLAY));
&ADVLockClose (DISPLAY, "$AccountName.txt");
$PresenceCheck = 0;
unless ($cryptword || !($RequireAdminApproval)) {
&ADVLockOpen (COUNT, "adlist.txt");
@lines = $text{'9051'} ";
print ""$AccountName" $text{'9052'}\n";
&Footer;
}
&ConfirmUserPassword;
&Header("$text{'1000'}","$text{'1001'}");
print " $text{'9051'} ";
print ""$AccountName" $text{'9052'}\n";
&Footer;
}
&ConfirmAdminPassword(1);
&Header("$text{'1000'}","$text{'1001'}");
print " (Please note that deleting the group will ";
print "not delete or otherwise affect the adverts ";
print "themselves. Only the ability to view all their stats ";
print "on a single page will be gone!)\n";
&Footer;
}
sub newpass {
unless ($INPUT{'passad'} && ($INPUT{'passad'} eq $INPUT{'passad2'})) {
&Header("$text{'9000'}","$text{'9024'}");
print " $text{'9025'}\n";
&Footer;
}
open (PASSWORD, "<$ADVadverts_dir/adpassword.txt");
$password = $text{'9021'}\n";
&Footer;
}
unless ($newpassword eq $password) {
&Header("$text{'9000'}","$text{'9022'}");
print " $text{'9023'}\n";
&Footer;
}
}
$newpassword = crypt($INPUT{'passad'}, "aa");
&ADVLockOpen (PASSWORD, "adpassword.txt");
seek (PASSWORD,0,0);
print PASSWORD "$newpassword";
truncate (PASSWORD,tell(PASSWORD));
&ADVLockClose (PASSWORD,"adpassword.txt");
&Header("$text{'1000'}","$text{'1001'}");
print " Your administrative password ";
print "has been set.\n";
$INPUT{'password'} = $INPUT{'passad'};
&LinkBack;
&Footer;
}
sub resetcount {
&ConfirmAdminPassword(1);
&ADVLockOpen (DBMLIST, "dbmlist.txt");
if ($ADVlockerror) { &Error_DBM; }
else {
&ADVDBMOpen;
if ($ADVdbmerror) { &Error_DBM; }
else {
$DBMList{'adcount.txt'} = "1\n0\n$time";
&ADVDBMClose;
}
}
&ADVLockClose (DBMLIST, "dbmlist.txt");
if ($AdminDisplaySetup) { &defineview; }
else {
$INPUT{'whichtype'} = "pending established groups";
$INPUT{'whichtime'} = "active expired disabled";
$INPUT{'whichzone'} = "";
&reviewall;
}
}
sub editfinal {
$AccountName = $INPUT{'editad'};
&CheckName;
unless (!(-s "$ADVadverts_dir/$subdir/$AccountName.txt")
&& $AllowUserEdit && $INPUT{'newuser'}) {
&ConfirmUserPassword;
}
if (-s "$ADVadverts_dir/$subdir/$AccountName.txt") {
open (DISPLAY, "<$ADVadverts_dir/$subdir/$AccountName.txt");
@advertlines = $text{'9101'}\n";
&Footer;
}
if ((($maxtype eq "C") || ($maxtype eq "D")) && ($displayratio || $clicksratio)) {
&Header("$text{'9000'}","$text{'9110'}");
print " $text{'9111'}\n";
&Footer;
}
$PresenceCheck = 0;
if (-s "$ADVadverts_dir/adnew.txt") {
&ADVLockOpen (COUNT, "adnew.txt");
@lines =
\n";
}
print "
\n";
}
unless ($INPUT{'whichtype'}) { $INPUT{'whichtype'} = "established"; }
unless ($INPUT{'whichtime'}) { $INPUT{'whichtime'} = "active"; }
if ($INPUT{'whichtype'} =~ /established/) {
print "
(Zones Included: ";
print "$INPUT{'whichzone'})\n";
}
}
open (LIST, "<$ADVadverts_dir/adlist.txt");
@advertisements = ;
close (LIST);
chomp (@advertisements);
@sortedadverts = sort (@advertisements);
&ADVLockOpen (DBMLIST, "dbmlist.txt");
if ($ADVlockerror) { &Error_DBM; }
else {
&ADVDBMOpen;
if ($ADVdbmerror) { &Error_DBM; }
else {
foreach $advertiser (@sortedadverts) {
$name = $advertiser;
next if (length($advertiser) < 1);
($max,$shown,$visits,$image,$start,$weight,
$zone,$raw,$displayratio,$clicksfrom) = split(/\t/,$DBMList{$name});
if (length($zone) > 2) { $ZoneColumn = 1; last; }
}
print "\n";
print "
Since $hour:$min on $mday $months[$mon] $year, ";
print "there have been a total of ",&commas($exposures);
print " advert exposures";
$time = $time - $starttime + 1;
if ($time > 86400) {
$average = int(($exposures/($time/86400))+.5);
print ",
for an average of ",&commas($average);
print " exposures per day";
}
}
print ".)\n";
if ($NotUsingBestDBM) {
print "
\n";
}
unless ($AlwaysAvailable) {
print "
\n";
}
}
}
print "
";
&ADVLockClose (DBMLIST, "dbmlist.txt");
}
if ((-s "$ADVadverts_dir/adnew.txt") && ($INPUT{'whichtype'} =~ /pending/)) {
undef @newlines;
open (COUNT, "<$ADVadverts_dir/adnew.txt");
@newlines =
";
}
if ((-s "$ADVadverts_dir/groups.txt") && ($INPUT{'whichtype'} =~ /groups/)) {
undef @grouplines;
open (COUNT, "<$ADVadverts_dir/groups.txt");
@grouplines = ;
close (LIST);
chomp (@advertlist);
foreach $advertiser (@advertlist) { &constructlist; }
$listtype = "pending";
open (LIST, "<$ADVadverts_dir/adnew.txt");
@advertlist =
;
close (LIST);
chomp (@advertlist);
foreach $advertiser (@advertlist) { &constructlist; }
@sortedemails1 = sort (@emails1);
@sortedemails2 = sort (@emails2);
&Header("$text{'1000'}","$text{'1001'}");
print "
"; }
print "$email\n";
$lastemail = $email;
}
print ";
close (LIST);
chomp (@advertlist);
open (LIST, "<$ADVadverts_dir/adexpirelist.txt");
@recipientlist =
;
close (LIST);
chomp (@recipientlist);
$recipientlist = join(' ',@recipientlist);
$recipientlist = " $recipientlist ";
foreach $advertiser (@advertlist) { &constructlist; }
@sortedemails1 = sort (@emails1);
&Header("$text{'1000'}","$text{'1001'}");
print "
"; }
print "$recipient\n";
print LIST "$recipient\n";
$lastrecipient = $recipient;
}
close (LIST);
&LinkBack;
&Footer;
}
sub reviewgroup {
$groupstatus = "$AccountName";
unless (-s "$ADVadverts_dir/$AccountName.grp") {
if ($AllowUserEdit && $INPUT{'newuser'}) {
&UserEdit;
}
&Header("$text{'9000'}","$text{'9050'}");
print "
\n";
&reviewadvert;
}
print "\n",
"
",
" \n";
if (($TotalShown == 0) || ($TotalVisits == 0)) {
$perc = "$text{'2020'}";
$ratio = "$text{'2020'}";
}
else {
$perc = ((100*($TotalVisits/$TotalShown))+.05001);
$ratio = (($TotalShown/$TotalVisits)+.5001);
}
unless ($perc eq "$text{'2020'}") {
$perc =~ s/(\d+\.\d).*/$1/;
$perc = $perc."%";
}
unless ($ratio eq "$text{'2020'}") {
$ratio =~ s/(\d+)\.\d.*/$1/;
$ratio = $ratio.":1";
}
print "$text{'2015'} ",
"$text{'2017'} ",
"$text{'2018'} ",
"$text{'2019'} ";
print " \n";
print "",&commas($TotalShown)," ";
print "",&commas($TotalVisits)," ";
print "$perc $ratio \n";
print "
\n";
print "";
print " \n";
print "$text{'2011'} ";
if ($displayratio || $displaycount || $clicksratio || $clicksfrom) {
print "$text{'2040'}";
print " ";
if ($clicksratio || $cryptword || $ShowClicksFrom) {
print "$text{'2041'}";
print " ";
print "$text{'2018'} ";
print "$text{'2019'} ";
}
print "";
if ($start) {
($sec,$min,$hour,$mday,$mon,$year,
$wday,$yday,$isdst) = localtime($start+($ADVHourOffset*3600));
$year += 1900;
print " \n";
print "$mday $months[$mon] $year ";
$runtime = $time - $start + 1;
}
else { print ""; }
if (($displaycount == 0) || ($clicksfrom == 0)) {
$foreignperc = "$text{'2020'}";
$foreignratio = "$text{'2020'}";
}
else {
$foreignperc = ((100*($clicksfrom/$displaycount))+.05001);
$foreignratio = (($displaycount/$clicksfrom)+.5001);
}
unless ($foreignperc eq "$text{'2020'}") {
$foreignperc =~ s/(\d+\.\d).*/$1/;
$foreignperc = $foreignperc."%";
}
unless ($foreignratio eq "$text{'2020'}") {
$foreignratio =~ s/(\d+)\.\d.*/$1/;
$foreignratio = $foreignratio.":1";
}
print " ",&commas($displaycount)," ";
if ($clicksratio || $cryptword || $ShowClicksFrom) {
print "",&commas($clicksfrom)," ";
print "$foreignperc ";
print "$foreignratio ";
}
print "\n";
print "
";
}
else {
print " \n";
if (($shown == 0) || ($visits == 0)) {
$perc = "$text{'2020'}";
$ratio = "$text{'2020'}";
}
else {
$perc = ((100*($visits/$shown))+.05001);
$ratio = (($shown/$visits)+.5001);
}
unless ($perc eq "$text{'2020'}") {
$perc =~ s/(\d+\.\d).*/$1/;
$perc = $perc."%";
}
unless ($ratio eq "$text{'2020'}") {
$ratio =~ s/(\d+)\.\d.*/$1/;
$ratio = $ratio.":1";
}
print "$text{'2012'} ";
}
if ($image || $raw || $shown || $visits) {
print "$text{'2030'}";
print " ";
print "$text{'2016'} ";
print "$text{'2031'}";
print " ";
print "$text{'2018'} ";
print "$text{'2019'} ";
}
print "";
$runtime = 0;
if ($start) {
($sec,$min,$hour,$mday,$mon,$year,
$wday,$yday,$isdst) = localtime($start+($ADVHourOffset*3600));
$year += 1900;
unless ($displayratio || $displaycount || $clicksratio || $clicksfrom) {
print " $mday $months[$mon] $year ";
}
$runtime = $time - $start + 1;
}
else {
unless ($displayratio || $displaycount || $clicksratio || $clicksfrom) {
print "";
}
}
$average = 0;
if (($weight > 0) && ($runtime > 86400)) {
&GetAverage;
}
unless ($displayratio || $clicksratio) {
if ($maxtype eq "D") {
($sec,$min,$hour,$mday,$mon,$year,
$wday,$yday,$isdst) = localtime($max+($ADVHourOffset*3600));
$year += 1900;
print " $mday $months[$mon] $year";
unless ($max > $time) {
$expired = 1;
print " ";
}
elsif ($maxtype eq "N") {
print "
$text{'2100'}";
}
print "$text{'2101'} ";
}
else {
print "",&commas($max);
if ($maxtype eq "C") {
print " $text{'2110'}";
if (($average == 0) || ($shown == 0) || ($visits == 0)) {
print " ";
}
}
if ($image || $raw || $shown || $visits) {
print "
$text{'2102'}";
}
elsif ($max > $visits) {
$daystogo = (($max-$visits)/($average*($visits/$shown)));
$calculatedend = $time+($daystogo*86400);
($sec,$min,$hour,$mday,$mon,$year,
$wday,$yday,$isdst) = localtime($calculatedend+($ADVHourOffset*3600));
$year += 1900;
print "
(~ $mday $months[$mon] $year)";
}
else {
$expired = 1;
print "
$text{'2100'}";
}
}
else {
print " $text{'2111'}";
if ($average == 0) {
print "
$text{'2102'}";
}
elsif ($max > $shown) {
$daystogo = (($max-$shown)/$average);
$calculatedend = $time+($daystogo*86400);
($sec,$min,$hour,$mday,$mon,$year,
$wday,$yday,$isdst) = localtime($calculatedend+($ADVHourOffset*3600));
$year += 1900;
print "
(~ $mday $months[$mon] $year)";
}
else {
$expired = 1;
print "
$text{'2100'}";
}
}
print "",&commas($shown)," ";
if ($expired || ($weight < 1)) {
print "-- ";
}
elsif ($average > 0) {
print "",&commas($average)," ";
}
else {
print "$text{'2020'} ";
}
print "",&commas($visits)," ";
print "$perc $ratio ";
}
print "
";
}
unless ($ExchangeBorder) { $ExchangeBorder = "0"; }
$HTMLCode .= "<P><CENTER>";
if ($ExchangeLogo
&& (($ExchangeLogoPosition =~ /^t/i)
|| ($ExchangeLogoPosition =~ /^l/i)
|| ($ExchangeLogoPosition =~ /^1/i)
|| !($ExchangeLogoPosition))) {
if ($ExchangeURL) {
$HTMLCode .= "<A HREF="$ExchangeURL"";
$HTMLCode .= " $DefaultLinkAttribute>";
}
$HTMLCode .= "<IMG SRC="$ExchangeLogo"";
if ($ExchangeLogoHeight && $ExchangeLogoWidth) {
$HTMLCode .= " WIDTH=$ExchangeLogoWidth";
$HTMLCode .= " HEIGHT=$ExchangeLogoHeight";
}
if ($ExchangeName) {
$HTMLCode .= " ALT="$ExchangeName"";
}
$HTMLCode .= " BORDER=$ExchangeBorder>";
if ($ExchangeURL) {
$HTMLCode .= "</A>";
}
if ($ExchangeLogoPosition =~ /^t/i) {
$HTMLCode .= "<BR>";
}
}
if ($JavaScriptExchange) {
$HTMLCode .= "<SCRIPT LANGUAGE="JavaScript" ";
$HTMLCode .= "SRC="$nonssi_cgi?";
$HTMLCode .= "jscript;member=$name";
if ($displayzone) {
$HTMLCode .= ";zone=$displayzone";
}
$HTMLCode .= "">";
$HTMLCode .= "</SCRIPT>";
$HTMLCode .= "<NOSCRIPT>";
}
if ($IFRAMEexchange) {
$HTMLCode .= "<IFRAME SRC="$nonssi_cgi?";
$HTMLCode .= "iframe;member=$name";
if ($displayzone) {
$HTMLCode .= ";zone=$displayzone";
}
$HTMLCode .= """;
$HTMLCode .= " MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0";
$HTMLCode .= " FRAMEBORDER=0 SCROLLING=NO";
if ($ExchangeBannerHeight && $ExchangeBannerWidth) {
$IFRAMEWidth = $ExchangeBannerWidth+($DefaultBorder*2);
$IFRAMEHeight = $ExchangeBannerHeight+($DefaultBorder*2);
$HTMLCode .= " WIDTH=$IFRAMEWidth";
$HTMLCode .= " HEIGHT=$IFRAMEHeight";
}
$HTMLCode .= ">";
}
$HTMLCode .= "<A HREF="$nonssi_cgi?";
$HTMLCode .= "member=$name;banner=NonSSI;page=01";
if ($displayzone) {
$HTMLCode .= ";zone=$displayzone";
}
$HTMLCode .= """;
$HTMLCode .= " $DefaultLinkAttribute>";
$HTMLCode .= "<IMG SRC="$nonssi_cgi?";
$HTMLCode .= "member=$name;page=01";
if ($displayzone) {
$HTMLCode .= ";zone=$displayzone";
}
$HTMLCode .= """;
if ($ExchangeBannerHeight && $ExchangeBannerWidth) {
$HTMLCode .= " WIDTH=$ExchangeBannerWidth";
$HTMLCode .= " HEIGHT=$ExchangeBannerHeight";
}
if ($ExchangeName) {
$HTMLCode .= " ALT="$ExchangeName"";
}
$HTMLCode .= " BORDER=$DefaultBorder></A>";
if ($IFRAMEexchange) {
$HTMLCode .= "</IFRAME>";
}
if ($JavaScriptExchange) {
$HTMLCode .= "</NOSCRIPT>";
}
if ($ExchangeLogo
&& (($ExchangeLogoPosition =~ /^b/i)
|| ($ExchangeLogoPosition =~ /^r/i))) {
if ($ExchangeLogoPosition =~ /^b/i) {
$HTMLCode .= "<BR>";
}
if ($ExchangeURL) {
$HTMLCode .= "<A HREF="$ExchangeURL"";
$HTMLCode .= " $DefaultLinkAttribute>";
}
$HTMLCode .= "<IMG SRC="$ExchangeLogo"";
if ($ExchangeLogoHeight && $ExchangeLogoWidth) {
$HTMLCode .= " WIDTH=$ExchangeLogoWidth";
$HTMLCode .= " HEIGHT=$ExchangeLogoHeight";
}
if ($ExchangeName) {
$HTMLCode .= " ALT="$ExchangeName"";
}
$HTMLCode .= " BORDER=$ExchangeBorder>";
if ($ExchangeURL) {
$HTMLCode .= "</A>";
}
}
if ($ExchangeName && !($ExchangeLogo)) {
$HTMLCode .= "<BR><SMALL>";
if ($ExchangeURL) {
$HTMLCode .= "<A HREF="$ExchangeURL"";
$HTMLCode .= " $DefaultLinkAttribute>";
}
$HTMLCode .= "$ExchangeName";
if ($ExchangeURL) {
$HTMLCode .= "</A>";
}
$HTMLCode .= "</SMALL>";
}
$HTMLCode .= "</CENTER>";
if ($ExchangeName) {
$HTMLCode .= "\n
<!-- End $ExchangeName Code -->\n";
}
print "
\n";
}
print "\n";
print "\n";
if ($UserUploadDir) {
print "\n";
}
print "\n";
print " \n";
if ($LogByZone) {
print "\n";
}
print "\n";
print "\n";
if ($ADVLogIP) {
print "\n";
}
print "
//g;
$HTMLCode =~ s/<//g;
$HTMLCode =~ s/"/"/g;
$body =~ s/<--UserID-->/$name/g;
$body =~ s/<--Password-->/$pass/g;
$body =~ s/<--HTMLCode-->/$HTMLCode/g;
&SendMail($email,"welcome");
}
&ShowAdvert;
}
sub GetAverage {
$subdir = substr($name,0,1);
$subdir .= "/$name";
open (DISPLAY, "<$ADVadverts_dir/$subdir/$name.log");
@lines = \n";
print "
\n";
}
print "";
print " \n";
foreach $key (sort (keys %exposures)) {
($zone,$member) = split(/\s/,$key);
unless ($clicks{$key}) { $clicks{$key} = "0"; }
print "$text{'2212'} ";
print "$text{'2213'} ";
print "$text{'2214'} ";
print "$text{'2215'} ";
print "$text{'2018'} ";
print "$text{'2019'} ";
print "";
if (($exposures{$key} == 0) || ($clicks{$key} == 0)) {
$perc = "$text{'2020'}";
$ratio = "$text{'2020'}";
}
else {
$perc = ((100*($clicks{$key}/$exposures{$key}))+.05001);
$ratio = (($exposures{$key}/$clicks{$key})+.5001);
}
unless ($perc eq "$text{'2020'}") {
$perc =~ s/(\d+\.\d).*/$1/;
$perc = $perc."%";
}
unless ($ratio eq "$text{'2020'}") {
$ratio =~ s/(\d+)\.\d.*/$1/;
$ratio = $ratio.":1";
}
print " \n";
}
print "$zone ";
print "$member ";
print "",&commas($exposures{$key})," ";
print "",&commas($clicks{$key})," ";
print "$perc ";
print "$ratio ";
print "\n";
print "\n";
print "\n";
print "\n";
if ($ADVLogIP) {
print "\n";
}
print "
$text{'2222'}";
}
elsif ($INPUT{'FullDailyList'}) {
print "
$text{'2223'}";
}
print ":\n";
print "\n";
print "
";
print " $text{'2224'} ";
if ($bannex) {
print " ";
print "$text{'2040'}";
print " ";
$ColCountA = 2;
if ($INPUT{'showclicksfrom'}) {
print "$text{'2041'}";
print " ";
print "$text{'2018'} ";
$ColCountA += 6;
}
}
if ($beingshown) {
print " ";
print "$text{'2030'}";
print " ";
print "$text{'2031'}";
print " ";
print "$text{'2018'} ";
$ColCountB = 8;
}
$daycounter = (($endday-$startday)+1);
if ($TotalE) { $MultE = ((49.5/($MaxE/$TotalE))/$daycounter); }
if ($TotalC) { $MultC = ((49.5/($MaxC/$TotalC))/$daycounter); }
if ($TotalS) { $MultS = ((49.5/($MaxS/$TotalS))/$daycounter); }
if ($TotalX) { $MultX = ((49.5/($MaxX/$TotalX))/$daycounter); }
foreach $daycount ($startday..$endday) {
print "";
if (($daycount > $startday)
&& ($daycount-(int($daycount/7)*7)==3)) {
print " \n";
print " ";
if ($ColCountA) {
print " ";
print " ";
}
if ($ColCountB) {
print " ";
print " ";
}
print "";
}
&count_to_date($daycount);
if ($perp_mon < 10) { $perp_mon = "0$perp_mon"; }
if ($perp_day < 10) { $perp_day = "0$perp_day"; }
$perp_year = $perp_year + 1900;
print " \n";
}
}
print "$perp_day $months[$perp_mon-1] $perp_year ";
$banners = "$perp_day $perp_mon $perp_year S";
$clicksfrom = "$perp_day $perp_mon $perp_year X";
$exposures = "$perp_day $perp_mon $perp_year E";
$clicks = "$perp_day $perp_mon $perp_year C";
$banners = $accesses{$banners};
if (($TotalS == 0) || ($banners==$TotalS)) { $bannerspercent = 0; }
else { $bannerspercent=int((($banners/$TotalS)*($daycounter*$MultS))+.5); }
$clicksfrom = $accesses{$clicksfrom};
if (($TotalX == 0) || ($clicksfrom==$TotalX)) { $clicksfrompercent = 0; }
else { $clicksfrompercent=int((($clicksfrom/$TotalX)*($daycounter*$MultX))+.5); }
$exposures = $accesses{$exposures};
if (($TotalE == 0) || ($exposures==$TotalE)) { $exposurespercent = 0; }
else { $exposurespercent=int((($exposures/$TotalE)*($daycounter*$MultE))+.5); }
$clicks = $accesses{$clicks};
if (($TotalC == 0) || ($clicks==$TotalC)) { $clickspercent = 0; }
else { $clickspercent=int((($clicks/$TotalC)*($daycounter*$MultC))+.5); }
if ($banners < 1) { $banners = "0"; }
if ($clicksfrom < 1) { $clicksfrom = "0"; }
if ($exposures < 1) { $exposures = "0"; }
if ($clicks < 1) { $clicks = "0"; }
if ($bannex) {
print " ";
print "",&commas($banners)," ";
if ($bannerspercent==0) { print " "; }
else { print " "; }
if ($INPUT{'showclicksfrom'}) {
print " ",&commas($clicksfrom)," ";
if ($clicksfrompercent==0) { print " "; }
else { print " "; }
if ($banners == 0) { $perc = "-"; }
elsif ($clicksfrom == 0) { $perc = "-"; }
else { $perc = ((100*($clicksfrom/$banners))+.05001); }
unless ($perc eq "-") {
$perc =~ s/(\d+\.\d).*/$1/;
$perc = $perc."%";
}
print " $perc ";
}
}
if ($beingshown) {
print " ";
print "",&commas($exposures)," ";
if ($exposurespercent==0) { print " "; }
else { print " "; }
print " ",&commas($clicks)," ";
if ($clickspercent==0) { print " "; }
else { print " "; }
if ($exposures == 0) { $perc = "-"; }
elsif ($clicks == 0) { $perc = "-"; }
else { $perc = ((100*($clicks/$exposures))+.05001); }
unless ($perc eq "-") {
$perc =~ s/(\d+\.\d).*/$1/;
$perc = $perc."%";
}
print " $perc ";
print "\n";
print "\n";
if ($LogByZone) {
print "\n";
}
print "\n";
if ($ADVLogIP) {
print "\n";
}
print " \n";
print "
";
print " $text{'2232'} ";
if ($bannex) {
print " ";
print "$text{'2040'}";
print " ";
if ($INPUT{'showclicksfrom'}) {
print "$text{'2041'}";
print " ";
print "$text{'2018'} ";
}
}
if ($beingshown) {
print " ";
print "$text{'2030'}";
print " ";
print "$text{'2031'}";
print " ";
print "$text{'2018'} ";
}
foreach $year ($startyear..$endyear) {
if ($year == $startyear) { $firstmon = $startmon; }
else { $firstmon = "01"; }
if ($year == $endyear) { $lastmon = $endmon; }
else { $lastmon = 12; }
foreach $month ($firstmon..$lastmon) {
$TestS = "$month $year S";
$TestX = "$month $year X";
$TestE = "$month $year E";
$TestC = "$month $year C";
if ($accesses{$TestS} > $MaxS) { $MaxS = $accesses{$TestS}; }
if ($accesses{$TestX} > $MaxX) { $MaxX = $accesses{$TestX}; }
if ($accesses{$TestE} > $MaxE) { $MaxE = $accesses{$TestE}; }
if ($accesses{$TestC} > $MaxC) { $MaxC = $accesses{$TestC}; }
$monthcounter++;
}
}
if ($TotalE) { $MultE = ((49.5/($MaxE/$TotalE))/$monthcounter); }
if ($TotalC) { $MultC = ((49.5/($MaxC/$TotalC))/$monthcounter); }
if ($TotalS) { $MultS = ((49.5/($MaxS/$TotalS))/$monthcounter); }
if ($TotalX) { $MultX = ((49.5/($MaxX/$TotalX))/$monthcounter); }
foreach $year ($startyear..$endyear) {
if ($year == $startyear) { $firstmon = $startmon; }
else { $firstmon = "01"; }
if ($year == $endyear) { $lastmon = $endmon; }
else { $lastmon = 12; }
foreach $month ($firstmon..$lastmon) {
print "";
print " \n";
}
}
}
print "$months[$month-1] $year ";
unless (length($month) == 2) { $month = "0".$month; }
$banners = "$month $year S";
$clicksfrom = "$month $year X";
$exposures = "$month $year E";
$clicks = "$month $year C";
$banners = $accesses{$banners};
if (($TotalS == 0) || ($banners==$TotalS)) { $bannerspercent = 0; }
else { $bannerspercent=int((($banners/$TotalS)*($monthcounter*$MultS))+.5); }
$clicksfrom = $accesses{$clicksfrom};
if (($TotalX == 0) || ($clicksfrom==$TotalX)) { $clicksfrompercent = 0; }
else { $clicksfrompercent=int((($clicksfrom/$TotalX)*($monthcounter*$MultX))+.5); }
$exposures = $accesses{$exposures};
if (($TotalE == 0) || ($exposures==$TotalE)) { $exposurespercent = 0; }
else { $exposurespercent=int((($exposures/$TotalE)*($monthcounter*$MultE))+.5); }
$clicks = $accesses{$clicks};
if (($TotalC == 0) || ($clicks==$TotalC)) { $clickspercent = 0; }
else { $clickspercent=int((($clicks/$TotalC)*($monthcounter*$MultC))+.5); }
if ($banners < 1) { $banners = "0"; }
if ($clicksfrom < 1) { $clicksfrom = "0"; }
if ($exposures < 1) { $exposures = "0"; }
if ($clicks < 1) { $clicks = "0"; }
if ($bannex) {
print " ";
print "",&commas($banners)," ";
if ($bannerspercent==0) { print " "; }
else { print " "; }
if ($INPUT{'showclicksfrom'}) {
print " ",&commas($clicksfrom)," ";
if ($clicksfrompercent==0) { print " "; }
else { print " "; }
if ($banners == 0) { $perc = "-"; }
elsif ($clicksfrom == 0) { $perc = "-"; }
else { $perc = ((100*($clicksfrom/$banners))+.05001); }
unless ($perc eq "-") {
$perc =~ s/(\d+\.\d).*/$1/;
$perc = $perc."%";
}
print " $perc ";
}
}
if ($beingshown) {
print " ";
print "",&commas($exposures)," ";
if ($exposurespercent==0) { print " "; }
else { print " "; }
print " ",&commas($clicks)," ";
if ($clickspercent==0) { print " "; }
else { print " "; }
if ($exposures == 0) { $perc = "-"; }
elsif ($clicks == 0) { $perc = "-"; }
else { $perc = ((100*($clicks/$exposures))+.05001); }
unless ($perc eq "-") {
$perc =~ s/(\d+\.\d).*/$1/;
$perc = $perc."%";
}
print " $perc ";
print "\n";
print "\n";
if ($LogByZone) {
print "\n";
}
print "\n";
if ($ADVLogIP) {
print "\n";
}
print " ";
($mday,$mon) = (localtime($time-86400+($ADVHourOffset*3600)))[3,4];
if ($mday < 10) { $mday = "0".$mday; }
$mon++;
if ($mon < 10) { $mon = "0".$mon; }
open (DISPLAY, "$ADVadverts_dir/$subdir/$AccountName.$mon$mday.log");
&ShowIPs;
close (DISPLAY);
($mday,$mon) = (localtime($time+($ADVHourOffset*3600)))[3,4];
if ($mday < 10) { $mday = "0".$mday; }
$mon++;
if ($mon < 10) { $mon = "0".$mon; }
open (DISPLAY, "$ADVadverts_dir/$subdir/$AccountName.$mon$mday.log");
&ShowIPs;
close (DISPLAY);
print "
\n";
print "
$text{'2244'}: ",&commas($ClickCount),"\n";
print "
$text{'2245'}: ",&commas($IPCount),"\n";
if ($IPCount<1) { $AverageEntries = 0; }
else { $AverageEntries = (($ExposureCount+$ClickCount)/$IPCount)+.05; }
if ($AverageEntries < 10) {
$AverageEntries =~ s/(...).*/$1/;
}
else {
$AverageEntries =~ s/(....).*/$1/;
}
print "\n";
print "\n";
if ($LogByZone) {
print "\n";
}
print "\n";
print "\n";
print "
Total clicks logged: ",&commas($ClickCount),"\n";
print "
Total IP addresses logged: ",&commas($IPCount),"\n";
if ($IPCount<1) { $AverageEntries = 0; }
else { $AverageEntries = (($ExposureCount+$ClickCount)/$IPCount)+.05; }
if ($AverageEntries < 10) {
$AverageEntries =~ s/(...).*/$1/;
}
else {
$AverageEntries =~ s/(....).*/$1/;
}
print "\n";
foreach $key (sort ByCount keys(%IPCount)) {
last if ($Counter > 49);
$ip = $key;
printf "%10s%-s\n",&commas($IPCount{$key})," $ip";
$Counter++;
}
print "
\n";
&LinkBack;
&Footer;
}
sub ByCount {
$IPCount{$b}<=>$IPCount{$a};
}
sub cheatercheck {
&ConfirmAdminPassword(1);
&Header("$text{'1000'}","$text{'1001'}");
print ";
close (LIST);
chomp (@advertisements);
@sortedadverts = sort (@advertisements);
&ADVLockOpen (DBMLIST, "dbmlist.txt");
if ($ADVlockerror) { &Error_DBM; }
else {
&ADVDBMOpen;
if ($ADVdbmerror) { &Error_DBM; }
else {
print "
\n",
"
",
" \n";
foreach $advertiser (@sortedadverts) {
$name = $advertiser;
next if (length($advertiser) < 1);
($max,$shown,$visits,$image,$start,$weight,
$zone,$raw,$displayratio,$clicksfrom) = split(/\t/,$DBMList{$name});
($displayratio,$displaycount) = split(/\|/, $displayratio);
($clicksfrom,$clicksratio) = split(/\|/, $clicksfrom);
next unless (($displayratio > 0) || ($displaycount > 0)
|| ($clicksfrom > 0) || ($clicksratio > 0));
if (($displaycount == 0) || ($clicksfrom == 0)) {
$perc = "$text{'2020'}";
$ratio = "$text{'2020'}";
}
else {
$perc = ((100*($clicksfrom/$displaycount))+.05001);
$ratio = (($displaycount/$clicksfrom)+.5001);
}
unless ($perc eq "$text{'2020'}") {
$perc =~ s/(\d+\.\d).*/$1/;
$perc = $perc."%";
}
unless ($ratio eq "$text{'2020'}") {
$ratio =~ s/(\d+)\.\d.*/$1/;
$ratio = $ratio.":1";
}
print "Account ",
"Banners Shown ",
"
on Your SiteClicks From ",
"
Your Site% ",
"Ratio \n",
" \n";
}
&ADVDBMClose;
print "$advertiser \n";
print "",&commas($displaycount)," ";
print "",&commas($clicksfrom)," ";
print "$perc $ratio
";
&ADVLockClose (DBMLIST, "dbmlist.txt");
&LinkBack;
&Footer;
}
sub ShowAdvert {
@image = split(/\|/,$image);
$url =~ s/";
}
if ($raw) {
$realraw = $raw;
$realraw =~ s/ $realraw ";
}
elsif ($image) {
print "";
foreach $image (@image) {
$img = $image;
$img =~ s/ ";
}
if ($raw || $image) {
print "
";
}
if ($url) {
print "";
}
print "";
if ($url) { print ""; }
if ($text && ($texttype eq "B")) {
print "
$text";
}
print "\n";
}
print "
"; }
else { print "\n";
open (ADMINLOG,"$ADVadverts_dir/adminlog.txt");
while (
\n";
print "