FREE Online Affiliate Program
www.WebpageAffiliates.com
Copyright © - updated by www.WebpagePublicity.com
Signup | Affiliate Training Videos | Login
#!/usr/bin/perl
##############################################################
# #
# Ultimate Affiliate #
# ***********SQL EDITION********** #
# By Steve Miles #
# http://www.groundbreak.com #
# #
# Copyright 1998-present #
# #
# Selling or distributing this software or #
# modifications of this software without #
# permission is expressly forbidden. Permission #
# to modify the script for personal use is granted. #
# In all cases this header and copyright #
# must remain intact. All violators will be #
# PROSECUTED to the full extent. #
# #
##############################################################
use CGI::Carp qw(fatalsToBrowser);
use CGI qw (:standard);
$q = new CGI;
$|++;
foreach ($q->param) {${$_} = $q->param($_); ${$_} =~ s/\;//ig;}
require "config.cgi";
require "common.cgi";
$referer = $q->referer();
$ip = $q->remote_host();
$time = time(); &date;
&headers_footers;
&Create_DB_Connection;
&find_cookie;
$referred = $getcookie;
print $q->header;
if ($action) {
&check_referer;
&check_form;
&matrix;
&record_info;
if ($affiliate_valid_email eq 1) { &send_valid;}
elsif ($affiliates_pending eq 1) { &send_pending;}
else { &normal_finish; }
$sth->finish;
$dbh->disconnect;
exit;
}
elsif ($secret) {
&check_validation;
}
else {
&print_form;
}
######################## CHECK FORM REFERER
sub check_referer {
if ($check_referring_urls_signup eq 1) { if ($referer !~ /$refurl/ig) { &print_default("You can't get in from here"); }}
}
######################## FIND THE COOKIE
sub find_cookie {
if ($affiliate) { $getcookie = $affiliate; }
else {
$getcookie = $q->cookie($cookiename);
if (!$getcookie) {$getcookie = "NO_SPONSOR";}
}
$Sponsor = $getcookie;
}
######################## Place in the matrix
sub matrix {
if ($matrix_on && $Sponsor) {
srand(time|$$);
$SQL="SELECT * FROM users"; &Do_SQL;
while ($row = $sth->fetchrow_hashref){
push @{ $kids{$row->{'Sponsor'}}}, $row->{'Username'};
}
if (@{$kids{$Sponsor}} < $matrix_width) { return; }
foreach $key (keys %kids) {
@new = ();
while (@{$kids{$key}}) {
push(@new, splice(@{$kids{$key}}, rand @{$kids{$key}}, 1));
}
@{$kids{$key}} = @new;
}
$kid = "$Sponsor";
&crunch(1);
}}
sub crunch {
if (!$foundthem) {
foreach $kid (@{$kids{$kid}}) {
$newlevel++;
$temp = $newlevel + 1;
if ($temp >= $matrix_height && !$gonespillover && $matrix_height) { $Sponsor = $spillover; $gonespillover++; &matrix; }
if (@{$kids{$kid}} < $matrix_width && !$foundthem) { $Sponsor = $kid; $foundthem++;}
&crunch($newlevel);
$newlevel--;
}}}
###########
# MAKE SURE EVERYTHING IS PROPER
###########
sub check_form {
my $count;
if (!$Username || $Username !~ /^[A-Za-z0-9]+$/) { $error .= "Username must consist of numbers and letters only";}
if (!$Password || $Password !~ /^[A-Za-z0-9]+$/) { $error .= "Passwords do not match";}
@reserved = split (/,/, $reserved);
foreach $item (@reserved) {
if ($item eq $Username) { $error .= "This username is reserved"; }
}
$count++ while $Username =~ /[A-Za-z0-9]/g;
if (4 > $count) { $error .= "You need more than 3 and less than 21 characters in your username";}
$count = 0;
$count++ while $Password =~ /[A-Za-z0-9]/g;
if (4 > $count) { $error .= "You need more than 3 and less than 21 characters in your password";}
if ($Password ne $Password2) { $error .= "Password and verify password don't match";}
if ($Email !~ /^[\w\-\.]+\@[\w\-]+\.[\w\-\.]+\w$/)
{ $error .= "Email is not in a valid format";}
if (!$Name)
{ $error .= "You must specify a name";}
if ($Terms ne "yes") { $error .= "You did not agree to the terms and conditions";}
if (!$auto_usernames) {
$SQL = "SELECT * FROM users WHERE Username like '$Username'"; &Do_SQL;
if ($sth->rows) { $error .= "Username already exists";}
}
$SQL = "SELECT * FROM users WHERE Email like '$Email'"; &Do_SQL;
if ($sth->rows) { $error .= "This email already exists in the system. Please visit our stats page to have your login info sent to you.";}
}
######################## RECORD THE INFORMATION
sub record_info {
if ($error) { &print_form; }
if ($affiliates_pending eq 1) { $status = "PENDING"; }
if ($affiliate_valid_email eq 1) {
srand;
@chars = ("A" .. "Z", "a" .. "z", 0 .. 9);
$valid_email = join("", @chars[ map {rand @chars } ( 1 .. 10) ]);
$status .= "VALIDATED=$valid_email";
}
@temp = (Field1,Field2,Field3,Field4,Field5);
foreach $item (@temp) {
push (@signupfields, $item);
}
if ($Username eq $Sponsor) { $Sponsor = "NO_SPONSOR"; }
foreach ($q->param) { ${$_} =~ s/\'/\\\'/g; ${$_} =~ s/\"/\\\"/g; }
$SQL = "INSERT INTO users (Year,Month,Day,Sponsor,Tier,Status,Username,Password,Email,Name,Address1,Address2,City,State,Zip,Country,Company,Sitename,Siteurl,Terms,Checkname,Phone,Fax,SSNumber, Field1, Field2, Field3, Field4, Field5, original_sponsor)
VALUES ('$year','$month','$day','$Sponsor','$tier','$status','$Username','$Password','$Email','$Name','$Address1','$Address2','$City','$State','$Zip','$Country','$Company','$Sitename','$Siteurl','$Terms','$Checkname','$Phone','$Fax','$SSNumber','$Field1','$Field2','$Field3','$Field4','$Field5', '$referred')";
&Do_SQL;
$sth->finish;
}
######################## SEND EMAIL VALIDATION INFO
sub send_valid {
print<
$header
Thank You for Signing Up! |
We require that you have a valid email address to join our affiliate program. An email
has just been sent to $Email containing a validation url to activate your account. Once
you click on this link, you will be able to log into the affiliate stats area. |
You will hear from us shortly!
You will be forwarded to our main page in 10 seconds. If not,
Click Here.
|
$footer
EOF
open (FILE, "$path_to_emails/validation_email.txt");
flock(FILE, 2);
(@email_stuff) = ();
flock(FILE, 8);
close (FILE);
$subject = shift (@email_stuff);
chomp $subject;
foreach $email_stuff (@email_stuff) {
$message .= $email_stuff;
}
foreach $thing ($q->param) {
$subject =~ s/\%\%$thing\%\%/${$thing}/ig;
$message =~ s/\%\%$thing\%\%/${$thing}/ig;
}
$temp_url = $url_to_clickthru;
$temp_url =~ s//$Username/ig;
$subject =~ s/\%\%affiliateurl\%\%/$temp_url/ig;
$message =~ s/\%\%affiliateurl\%\%/$temp_url/ig;
($firstname,$junk) = split (/ /, $Name);
$subject =~ s/\%\%firstname\%\%/$firstname/ig;
$message =~ s/\%\%firstname\%\%/$firstname/ig;
$url_to_stats = "$url_to_cgi_directory/stats.cgi?user=$Username&pass=$Password";
$subject =~ s/\%\%statsurl\%\%/$url_to_stats/ig;
$message =~ s/\%\%statsurl\%\%/$url_to_stats/ig;
$validation_url = "$url_to_cgi_directory/signup.cgi?secret=$valid_email";
$subject =~ s/\%\%validationurl\%\%/$validation_url/ig;
$message =~ s/\%\%validationurl\%\%/$validation_url/ig;
if ($smtphost) {
$smtp = Net::SMTP->new($smtphost);
$smtp->mail($admin_email);
$smtp->to($Email);
$smtp->data();
$smtp->datasend("From: $admin_email\n");
$smtp->datasend("To: $Email\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
$smtp->datasend("$message\n\n");
$smtp->dataend();
$smtp->quit();
} else {
open (MAIL, "|$mailprog -oi -t") || die "Can't open $path_to_sendmail!\n";
print MAIL <
$header
Thank You for Signing Up! |
Your affiliate status is awaiting our approval. Once you are
approved you will receive an email with all of the important login info and urls. Thank you. |
You will hear from us shortly!
You will be forwarded to our main page in 10 seconds. If not,
Click Here.
|
$footer
EOF
open (FILE, "$path_to_emails/pending_email.txt");
flock(FILE, 2);
(@email_stuff) = ();
flock(FILE, 8);
close (FILE);
$subject = shift (@email_stuff);
chomp $subject;
foreach $email_stuff (@email_stuff) {
$message .= $email_stuff;
}
if ($checked_validation) {
foreach $thing (@signupfields) {
$subject =~ s/\%\%$thing\%\%/${$thing}/ig;
$message =~ s/\%\%$thing\%\%/${$thing}/ig;
}
} else {
foreach $thing ($q->param) {
$subject =~ s/\%\%$thing\%\%/${$thing}/ig;
$message =~ s/\%\%$thing\%\%/${$thing}/ig;
}
}
($firstname,$junk) = split (/ /, $Name);
$subject =~ s/\%\%firstname\%\%/$firstname/ig;
$message =~ s/\%\%firstname\%\%/$firstname/ig;
$temp_url = $url_to_clickthru;
$temp_url =~ s//$Username/ig;
$subject =~ s/\%\%affiliateurl\%\%/$temp_url/ig;
$message =~ s/\%\%affiliateurl\%\%/$temp_url/ig;
$url_to_stats = "$url_to_cgi_directory/stats.cgi?user=$Username&pass=$Password";
$subject =~ s/\%\%statsurl\%\%/$url_to_stats/ig;
$message =~ s/\%\%statsurl\%\%/$url_to_stats/ig;
if ($smtphost) {
$smtp = Net::SMTP->new($smtphost);
$smtp->mail($admin_email);
$smtp->to($Email);
$smtp->data();
$smtp->datasend("From: $admin_email\n");
$smtp->datasend("To: $Email\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
$smtp->datasend("$message\n\n");
$smtp->dataend();
$smtp->quit();
} else {
open (MAIL, "|$mailprog -oi -t") || die "Can't open $path_to_sendmail!\n";
print MAIL <new($smtphost);
$smtp->mail($admin_email);
$smtp->to($admin_email);
$smtp->data();
$smtp->datasend("From: $admin_email\n");
$smtp->datasend("To: $admin_email\n");
$smtp->datasend("Subject: Another $main_site_name affiliate signup up!\n");
$smtp->datasend("\n");
$smtp->datasend("Another member has joined!\n\n");
foreach $field (@signupfields){
$smtp->datasend("$field : ${$field}\n");
}
$smtp->datasend("\n\n");
$smtp->datasend("Come check out your current affiliate statistics at:\n");
$smtp->datasend("$url_to_cgi_directory/admin.cgi");
$smtp->dataend();
$smtp->quit();
} else {
open (MAIL, "|$mailprog -oi -t") || die "Can't open /usr/sbin/sendmail!\n";
print MAIL <) { $filestuff .= $_; }
flock(FILE, 8);
close (FILE);
$filestuff =~ s/\%\%([a-zA-Z0-9_]+)\%\%/${$1}/ig;
$file =~ s/$path_to_templates//;
open (NEWFILE, ">$path_to_replicated_pages/$Username$file");
flock(NEWFILE, 2);
print NEWFILE $filestuff;
flock(NEWFILE, 8);
close (NEWFILE);
$filestuff = "";
}
}
}
####################### NORMAL FINISH
sub normal_finish {
$aftersignup =~ s//$Username/ig;
print<
SUCCESSFUL SIGNUP!
Successful Signup |
You will be forwarded in 5 seconds to the affiliate login page.
Click Here if nothing happens.
|