require_once("../includes/config.php");
#Check for ?ref= and set cookie if so
if($_GET[ref]){
if(!$_COOKIE["PerlCoders_Referer"]){ #no clobbering existing cookie
$cookiename = "PerlCoders_Referer";
$cookiedata = "$_GET[ref]";
$cookieexpire = time() + 31536000; #1 year from now
$value = "$cookiedata:$cookieexpire";
setcookie("$cookiename", $value, $cookieexpire, "/", ".$domain");
}
}
function joinmail(){
$ip = $_SERVER[REMOTE_ADDR] . " (" . gethostbyaddr($_SERVER[REMOTE_ADDR]) . ")";
$body .= << 16){
array_push($error, "Username has a maximum of 16 characters.");
}
if(!$_POST[password1]){
array_push($error, "You did not specify a password");
}
if($_POST[password2] != $_POST[password1]){
array_push($error, "The passwords you entered didn't match");
}
if(sizeof($error) > 0){
#we have errors
include("$incdir/header2.php");
echo "We're sorry, there were errors with your submission. They are outlined below. Please go back and try again.
";
echo "";
foreach($error as $var){
echo "- $var
";
}
echo "
";
include("$incdir/footer2.php");
exit;
}
else{
#Seems ok, lets add the fucker
$login = str_replace(" ", "", $_POST[username]);
$zip = str_replace("-", "", $_POST[zipcode]);
$phone = str_replace("-", "", $_POST[phone]);
$phone = str_replace("(", "", $phone);
$phone = str_replace(")", "", $phone);
$phone = str_replace(".", "", $phone);
$minpay = str_replace("\$", "", $_POST[payout_min]);
$minpay = sprintf("%.02f", $minpay);
$password = crypt($_POST[password1], "tA");
$time=time();
$query = "INSERT INTO affiliate_data SET name='$_POST[name]', street1='$_POST[street1]', street2='$_POST[street2]', city='$_POST[city]', state='$_POST[state]', zip='$_POST[zipcode]', country='$_POST[country]', phone='$_POST[phone]', email='$_POST[email]', website='$_POST[website]', minpay='$minpay', payvia='$_POST[payout_how]', taxid='$_POST[ssn]', login='$login', password='$password', balance='0.00', monthhits=0, yearhits=0, totalhits=0, comments='', lastactive='$time', lastip='$_SERVER[REMOTE_ADDR]'";
$result = mysql_query($query, $db);
if(mysql_affected_rows($db) > 0){
#success
joinmail();
$message = "Thank you for signing up for our affiliate program, we welcome you to the PerlCoders affiliate team! You can get started right away by logging in to the Affiliates' Area and grabbing banners, text descriptions, and link codes to promote the site. Good luck!";
include("$incdir/header2.php");
echo $message;
include("$incdir/footer2.php");
exit;
}
else
$message = "We're sorry, but we encountered a problem adding you to our affiliate database. Please try again later, or if this problem persists, email info@perlcoders.com to let us know. Thank you.";
include("$incdir/header2.php");
echo $message;
include("$incdir/footer2.php");
exit;
}
}
if($_GET[get] == "banners"){
$user = testaffiliatelogin(1);
include("$incdir/header2.php");
echo << Here are a few banners and buttons you can use to link to us. Remember, you must save the banner to your own server, please do not link directly to the images on our server from your site. |











EOT;
include("$incdir/footer2.php");
exit;
}
else if($_GET[get] == "descs"){
$user = testaffiliatelogin(1);
include("$incdir/header2.php");
echo <<Here are short descriptions of all our scripts. You can use these descriptions to promote the scripts on your own website or when listing the scripts in resource sites. Of course, you're also free to write your own descriptions.
EOT;
$result = mysql_query("SELECT scriptname,shortdesc FROM scripts", $db);
while($myrow = mysql_fetch_array($result)){
echo "- $myrow[scriptname]
$myrow[shortdesc] ";
}
echo << |
EOT;
include("$incdir/footer2.php");
exit;
}
else if($_GET[get] == "stats"){
$user = testaffiliatelogin(1);
$a = 0;
$result = mysql_query("SELECT * FROM affiliate_data WHERE login='$user'", $db);
$affilinfo = mysql_fetch_array($result);
#Figure out how many basic members this user has referred this month
$monthstart = mktime(0, 0, 0, date("m"), 1, date("Y"));
$result = mysql_query("SELECT COUNT(*) FROM customer_data WHERE created>=$monthstart AND referer='$user' AND platinum=0", $db);
if(mysql_num_rows($result) > 0){
$myrow = mysql_fetch_array($result);
$basmo = $myrow[0];
}
else{
$basmo = 0;
}
$earnmo = (float)($basmo * 5.00);
#Figure out how many basic members this user has referred this year
$yearstart = mktime(0, 0, 0, 1, 1, date("Y"));
$result = mysql_query("SELECT COUNT(*) FROM customer_data WHERE created>=$yearstart AND referer='$user' AND platinum=0", $db);
if(mysql_num_rows($result) > 0){
$myrow = mysql_fetch_array($result);
$basyr = $myrow[0];
}
else{
$basyr = 0;
}
$earnyr += (float)($basyr * 5.00);
#Figure out how many basic members this user has referred ever
$result = mysql_query("SELECT COUNT(*) FROM customer_data WHERE referer='$user' AND platinum=0", $db);
if(mysql_num_rows($result) > 0){
$myrow = mysql_fetch_array($result);
$bastot = $myrow[0];
}
else{
$bastot = 0;
}
$earntot += (float)($bastot * 5.00);
#Figure out how many platinum members this user has referred this month
$monthstart = mktime(0, 0, 0, date("m"), 1, date("Y"));
$result = mysql_query("SELECT COUNT(*) FROM customer_data WHERE created>$monthstart AND referer='$user' AND platinum=1", $db);
if(mysql_num_rows($result) > 0){
$myrow = mysql_fetch_array($result);
$platmo = $myrow[0];
}
else{
$platmo = 0;
}
$earnmo += (float)($platmo * 25.00);
#Figure out how many platinum members this user has referred this year
$yearstart = mktime(0, 0, 0, 1, 1, date("Y"));
$result = mysql_query("SELECT COUNT(*) FROM customer_data WHERE created>$yearstart AND referer='$user' AND platinum=1", $db);
if(mysql_num_rows($result) > 0){
$myrow = mysql_fetch_array($result);
$platyr = $myrow[0];
}
else{
$platyr = 0;
}
$earnyr += (float)($platyr * 25.00);
#Figure out how many platinum members this user has referred ever
$result = mysql_query("SELECT COUNT(*) FROM customer_data WHERE referer='$user' AND platinum=1", $db);
if(mysql_num_rows($result) > 0){
$myrow = mysql_fetch_array($result);
$plattot = $myrow[0];
}
else{
$plattot = 0;
}
$earntot += (float)($plattot * 25.00);
$template = @implode("", @file("$incdir/affil_stats.html"));
$template = str_replace("\$user", $user, $template);
$template = str_replace("\$hitsmo", $affilinfo[monthhits], $template);
$template = str_replace("\$hitsyr", $affilinfo[yearhits], $template);
$template = str_replace("\$hitstot", $affilinfo[totalhits], $template);
$template = str_replace("\$basmo", $basmo, $template);
$template = str_replace("\$basyr", $basyr, $template);
$template = str_replace("\$bastot", $bastot, $template);
$template = str_replace("\$platmo", $platmo, $template);
$template = str_replace("\$platyr", $platyr, $template);
$template = str_replace("\$plattot", $plattot, $template);
$template = str_replace("\$earnmo", sprintf("%.02f", $earnmo), $template);
$template = str_replace("\$earnyr", sprintf("%.02f", $earnyr), $template);
$template = str_replace("\$earntot", sprintf("%.02f", $earntot), $template);
include("$incdir/header2.php");
echo $template;
echo <<