#!/usr/local/bin/perl
#
# Program: bpmember.cgi
# Author: Drummond Miles
# Email: info@gadnet.com
#
# Created: 29/12/98
# Last Modified: 12/09/99 - removed references to $cgipath for ease of cross-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;
}
if ($indata{'showuser'})
{
&showuser;
}
elsif ($indata{'updateuser'})
{
&updateuser;
}
else
{
&getid;
}
sub getid
{
&header('Enter ID');
print("
\n");
&footer;
}
sub showuser
{
&header('Members Only');
$error = 0;
if (!$indata{'userid'})
{
$error = 1;
print("
Error
\n");
print("You must enter a User ID
\n");
}
if (!$indata{'userpass1'})
{
if (!$error)
{
print("
Error
\n");
$error = 1;
}
print("You must enter a Password
\n");
}
if (!(-e "$bpdata/$indata{'userid'}.txt") && ($indata{'userid'}))
{
if (!$error)
{
print("
Error
\n");
$error = 1;
}
print("Invalid User ID
\n");
print("(Note that User ID is case sensitive)
\n");
}
if ($error)
{
print ("
Use the \'Back\' button on your browser to correct your data\n");
return;
}
open (OLDUSER, "+<$bpdata/$indata{'userid'}.txt");
$lockfail = &lock("OLDUSER");
if ($lockfail)
{
&lockerror("$indata{'userid'}.txt");
}
@olduserlines = ;
close (OLDUSER);
foreach $olduserlines (@olduserlines)
{
chop $olduserlines if ($olduserlines =~ /\n$/);
}
if (@olduserlines[8] ne $indata{'userpass1'})
{
print ("
Error
\n");
print ("Invalid Password
\n");
print ("(Note that Password is case sensitive)
\n");
print ("
Use the \'Back\' button on your browser to correct your data\n");
return;
}
$userid = $indata{'userid'};
print "
User $indata{'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");
}
sub updateuser
{
&header('Update User');
$error = 0;
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");
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[13] = "0\n";
seek (OLDUSER,0,0);
truncate (OLDUSER,0);
foreach $olduserlines (@olduserlines)
{
chop $olduserlines if ($olduserlines =~ /\n$/);
print OLDUSER "$olduserlines\n";
}
close (OLDUSER);
$update = 1;
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";
}