#!/usr/local/bin/perl
#
# Program: bpadmmod.pl
# Author: Drummond Miles
# Email: info@gadnet.com
#
# Created: 29/12/98
# Last Modified: 12/09/99 - removed references to $cgipath for ease of multi-platform installation
# Copyright G.A.D.Miles 1998. All Rights Reserved
#
# Download script from http://www.gadnet.com/bplus
#
# This program is being distibuted as freeware. It can be freely downloaded and used.
# It may be modified as long as the copyright information remains intact.
#
# Any use of this program is entirely at the risk of the user. No liability will be
# accepted by the author.
#
# This code must not be sold, even in modified form, without the written permission
# of the author.
#
require "bpvars.txt";
require "bpsubs.cgi";
print "Content-type: text/html\n\n";
read(STDIN,$indata,$ENV{'CONTENT_LENGTH'});
@indata = split(/&/,$indata);
foreach $i (0..$#indata)
{
$indata[$i] =~ s/\+/ /g;
($key,$val) = split(/=/,$indata[$i],2);
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$indata{$key} .= "\0" if (defined($indata{$key}));
$indata{$key} .= $val;
}
$string = "?" . $ENV{'QUERY_STRING'};
if (($ENV{'QUERY_STRING'} =~ /unverified/) || ($ENV{'QUERY_STRING'} =~ /all/))
{
if (!$indata{'password'})
{
&header("Enter Administation Password");
print "
In order to access this function you must enter the adminstration password.\n";
print "
\n";
print "\n";
&footer;
}
else
{
open (PASSWORD, "+;
close (PASSWORD);
chop $indata{'password'} if ($indata{'password'} =~ /\n$/);
chop $password if ($password =~ /\n$/);
if ($password ne crypt($indata{'password'}, "dm"))
{
&header("Password Error");
print "
The password you entered is incorrect. Please try again.\n";
&footer;
}
}
}
if ($ENV{'QUERY_STRING'} =~ /unverified/)
{
$x = 0;
open (UNVERIFIED, "+<$bpdata/members.txt");
$lockfail = &lock("UNVERIFIED");
if ($lockfail)
{
&lockerror("members.txt");
}
while ()
{
chop if ($_ =~ /\n$/);
open (MEMBER, "+<$bpdata/$_.txt");
$lockfail = &lock("MEMBER");
if ($lockfail)
{
&lockerror("$_.txt");
}
@member = ;
close (MEMBER);
chop $member[13] if ($member[13] =~ /\n$/);
if (!$member[13])
{
@account[$x] = $_;
$x++;
}
}
close (UNVERIFIED);
@accounts = sort(@account);
&showaccts;
}
if ($ENV{'QUERY_STRING'} =~ /all/)
{
open (ALL, "+<$bpdata/members.txt");
$lockfail = &lock("ALL");
if ($lockfail)
{
&lockerror("members.txt");
}
@account = ;
close (ALL);
@accounts = sort(@account);
&showaccts;
}
elsif ($indata{'account'})
{
$val = $indata{'account'};
&showuser;
}
elsif ($indata{'updateuser'} || $indata{'deluser'})
{
&updateuser;
}
sub showaccts
{
if ($ENV{'QUERY_STRING'} =~ /all/)
{
&header('All Accounts');
}
else
{
&header('Unverified Accounts');
}
print("\n");
print("Account Information: \n");
print("User ID | \n");
print("Banners Displayed On Your Site | \n");
print("Displays of Your Banner | \n");
print("Click Throughs | \n");
print("Inception Date | \n");
print("
|
\n");
print("\n");
if (@accounts < 1)
{
print ("
There are Currently no Unverified Accounts | \n");
}
else
{
print("\n");
print(" |
\n");
&footer;
}
sub showuser
{
&header('Edit Member');
open (OLDUSER, "+<$bpdata/$val.txt");
$lockfail = &lock("OLDUSER");
if ($lockfail)
{
&lockerror("$val.txt");
}
@olduserlines = ;
close (OLDUSER);
foreach $olduserlines (@olduserlines)
{
chop $olduserlines if ($olduserlines =~ /\n$/);
}
$userid = $val;
print "
User $userid\n";
$earned = 0;
if (@olduserlines[5] > 0)
{
$earned = int(@olduserlines[4] / @olduserlines[5]);
}
$pc = "N/A";
if (@olduserlines[6] > 0)
{
$pc = (@olduserlines[7] * 100) / @olduserlines[6];
}
unless ($pc eq "N/A")
{
$pc =~ s/(.\d\d\d)\d*/$1/;
$pc = $pc . "%";
}
print("
\n");
print("User Statistics: |
\n");
print("Banners Displayed on this Site: | @olduserlines[4] | \n");
print("Credits Earned: | $earned | \n");
print("Credits Used: | @olduserlines[6] | \n");
print("Click Thrus to your Site: | @olduserlines[7] | \n");
print("Click Thru Percentage: | $pc | \n");
print("
|
\n");
print("\n");
&footer;
}
sub updateuser
{
&header('Update User');
$error = 0;
if ($indata{'button2'} && $indata{'deluser'})
{
open (UNVERIFIED, "+<$bpdata/members.txt");
$lockfail = &lock("UNVERIFIED");
if ($lockfail)
{
&lockerror("members.txt");
}
@unvlines =;
seek (UNVERIFIED,0,0);
truncate (UNVERIFIED,0);
foreach $unvlines (@unvlines)
{
chop $unvlines if ($unvlines =~ /\n$/);
next if $unvlines eq $indata{'userid'};
print UNVERIFIED "$unvlines\n";
}
close (UNVERIFIED);
unlink ("$bpdata/$indata{'userid'}.txt");
print("
Return to Main Administration Page");
&footer;
return;
}
if ($indata{'button2'})
{
print("
Are you sure you want to delete user $indata{'userid'}?");
print("\n");
&footer;
return;
}
if (!$indata{'username'})
{
$error = 1;
print("
Error
\n");
print("You must enter your Name
\n");
}
if (!$indata{'email'})
{
if (!$error)
{
print("
Error
\n");
$error = 1;
}
print("You must enter your Email Address
\n");
}
if (!$indata{'siteurl'})
{
if (!$error)
{
print("
Error
\n");
$error = 1;
}
print("You must enter the URL of your site
\n");
}
if (!$indata{'sitetitle'})
{
if (!$error)
{
print("
Error
\n");
$error = 1;
}
print("You must enter the title of your site
\n");
}
if ($error)
{
print ("
Use the \'Back\' button on your browser to correct your data\n");
&footer;
return;
}
open (OLDUSER, "+<$bpdata/$indata{'userid'}.txt");
$lockfail = &lock("OLDUSER");
if ($lockfail)
{
&lockerror("$indata{'userid'}.txt");
}
@olduserlines = ;
$olduserlines[0] = "$indata{'username'}\n";
$olduserlines[1] = "$indata{'email'}\n";
$olduserlines[2] = "$indata{'siteurl'}\n";
$olduserlines[9] = "$indata{'sitetitle'}\n";
$olduserlines[3] = "$indata{'urlbanner'}\n";
$olduserlines[5] = "$indata{'dispratio'}\n";
$olduserlines[13] = 1;
$olduserlines[14] = "$indata{'extracredits'}\n";
seek (OLDUSER,0,0);
truncate (OLDUSER,0);
foreach $olduserlines (@olduserlines)
{
chop $olduserlines if ($olduserlines =~ /\n$/);
print OLDUSER "$olduserlines\n";
}
close (OLDUSER);
print "
User $indata{'userid'} modified successfully\n";
print "
Please ensure that the following code is displayed on your page(s):\n";
&htmlcode($indata{'userid'});
print "
You must replace BOTH occurences of XX with a number between 01 and 99.
\n";
print "You must change both occurences of XX with the SAME number.
\n";
print "If you past this code onto more than one page, then each occurence of the code should have a DIFFERENT value for XX. \n";
print "In other words, if you place the code on two pages, BOTH occurences of XX could be 01 on the first page and 02 on the second page.\n";
&footer;
}