<?php
include "connect.php";
date_default_timezone_set("America/New_York");

if(!get_magic_quotes_gpc()) {
foreach($_POST as $key=>$value) {
$_POST[$key] = str_replace("'", "\'", $value);
}
} else {
foreach($_POST as $key=>$value) {
$_POST[$key] = str_replace('\"', '"', $value);
}
}


if(function_exists("session_is_registered")==false) {
function session_is_registered($name) {
return isset($_SESSION[$name]);
}
}

if(function_exists("session_register")==false) {
function session_register($name) {
$_SESSION[$name] = true;
}
}



$settings = mysql_query ( 'select * from settings' );

$settingrecord = mysql_fetch_array ( $settings );

while ( $settingrecord = mysql_fetch_array ( $settings ) ) {

$setting [$settingrecord ["name"]] = dbget($settingrecord ["setting"]);

}

$setting ['pay_with'] = unserialize ( $setting ['pay_with'] );

extract ( $setting );

$info=mysql_query ("select * from jse_settings where 1");
$record=mysql_fetch_array($info);
$amail=$record["amail"];
$exchangename=$record["exchangename"];

extract($setting);

if (isset($_SESSION["ulogin"])) 

{

$userinfo=mysql_query("Select *, memtypes.level From members Inner Join memtypes ON members.memtype = memtypes.memtype Where userid='".$_SESSION[uname]."'");
//$userinfo = mysql_query ( "select * from members where userid='" . $_SESSION [uname] . "'" );
$userrecord = mysql_fetch_array ( $userinfo );
$id = dbget($userrecord ["id"]);
$uid=$userrecord["id"];
$name = dbget($userrecord ["name"]);
$lastname = dbget($userrecord ["lastname"]);
$contact_email = dbget($userrecord ["contact_email"]);
$subscribed_email = dbget($userrecord ["subscribed_email"]);
$paypal_email = dbget($userrecord ["paypal_email"]);
$alertpayemail = dbget($userrecord ["alertpay_email"]);
$safepayemail = dbget($userrecord ["safepay_email"]);
$moneybookersemail = dbget($userrecord ["moneybookers_email"]);
$password = dbget($userrecord ["pword"]);
$userid = dbget($userrecord ["userid"]);
$status = dbget($userrecord ["status"]);
$referid = dbget($userrecord ["referid"]);
$verified = dbget($userrecord ["verified"]);
$solos = dbget($userrecord ["solos"]);
$points = dbget($userrecord ["points"]);
$commission = dbget($userrecord ["commission"]);
$ip = dbget($userrecord ["ip"]);
$joindate = dbget($userrecord ["joindate"]);
$lastpost = dbget($userrecord ["lastpost"]);
$subscribed = dbget($userrecord ["subscribed"]);
$memtype = dbget($userrecord ["memtype"]);
$memlevel = dbget($userrecord ["level"]);
$referrer = dbget($userrecord ["referrer"]);
$vacation = dbget($userrecord ["vacation"]);
$vacation_date = dbget($userrecord ["vacation_date"]);
$lastlogin = dbget($userrecord ["lastlogin"]);
$hits_unique = dbget($userrecord ["hits_unique"]);
$hits_visitor = dbget($userrecord ["hits_visitor"]);
$surf_clicks = dbget($userrecord ['surf_clicks']);
$surf_last_id = dbget($userrecord ['surf_last_id']);
$bounce=$userrecord["bounce"];
$vacation=$userrecord["vacation"];
$vacation_date=$userrecord["vacation_date"];

}
function dbput($txt) {
if (get_magic_quotes_gpc ()) {
$txt = stripslashes ( $txt );
}
if (function_exists ( 'mysql_real_escape_string' )) {
$txt = mysql_real_escape_string ( trim ( $txt ) );
} else {
$txt = addslashes ( trim ( $txt ) );
}
return $txt;
}
function dbget($txt) {
$txt = stripslashes ( trim ( $txt ) );
return $txt;
}
function dbgethtml($txt) {
$txt = stripslashes ( trim ( $txt ) );
$txt = htmlspecialchars ( $txt );
return $txt;
}
function otocommission($referid, $userid, $oto) {

$sql = mysql_query ( "SELECT * FROM members WHERE userid='$referid'" );

if (@mysql_num_rows ( $sql )) {

$info = mysql_fetch_array ( $sql );

if ($info ['memtype'] == "SUPER JV") {

$commission = $oto ['superjvcommission'];

} elseif ($info ['memtype'] == "JV Member") {

$commission = $oto ['jvcommission'];

} elseif ($info ['memtype'] == "PRO") {

$commission = $oto ['procommission'];

}

if ($commission) {

mysql_query ( "update members set commission=commission+" . $commission . " where userid='" . $referid . "'" );

mysql_query ( "INSERT INTO referraltrans VALUES ('id','$referid','Referral OTO Purchase $userid','" . time () . "','$$commission')" );

}

}

}

function buycommission($userid, $amount, $level = 1) {

global $probuycom, $probuycom2, $probuycom3, $probuycom4, $probuycom5, $jvbuycom, $jvbuycom2, $jvbuycom3, $jvbuycom4, $jvbuycom5, $superjvbuycom, $superjvbuycom2, $superjvbuycom3, $superjvbuycom4, $superjvbuycom5;

$probuycomvar = ($level == 1) ? 'probuycom' : 'probuycom' . $level;
$probuycomlvl = $$probuycomvar;

$jvbuycomvar = ($level == 1) ? 'jvbuycom' : 'jvbuycom' . $level;
$jvbuycomlvl = $$jvbuycomvar;

$superjvbuycomvar = ($level == 1) ? 'superjvbuycom' : 'superjvbuycom' . $level;
$superjvbuycomlvl = $$superjvbuycomvar;

if ($amount) {

$sql = mysql_query ( "SELECT * FROM members WHERE userid='$userid'" );

if (@mysql_num_rows ( $sql )) {

$info = mysql_fetch_array ( $sql );

if ($info ['memtype'] == "PRO") {
$percent = $probuycomlvl;
} elseif ($info ['memtype'] == "JV Member") {
$percent = $jvbuycomlvl;
} elseif ($info ['memtype'] == "SUPER JV") {
$percent = $superjvbuycomlvl;
}

if ($percent > 0 && is_numeric ( $percent )) {

$earn = $amount * $percent / 100;

mysql_query ( "update members set commission=commission+" . $earn . " where userid='" . $userid . "' LIMIT 1" );
mysql_query ( "INSERT INTO transactions VALUES ('id','$userid','Advertising Purchase Commissions Level '.$level,'" . time () . "','$$earn')" );

if (strlen ( $info ['referid'] ) > 0 && $level < 5) {
$newlevel = $level + 1;
buycommission ( $info ['referid'], $amount, $newlevel );
}
}

}

}

}

function assignpoints($userid, $points) {

global $propercent, $jvpercent, $superjvpercent;

if ($points) {

$sql = mysql_query ( "SELECT * FROM members WHERE userid='$userid'" );

if (@mysql_num_rows ( $sql )) {

$info = mysql_fetch_array ( $sql );

if ($info ['memtype'] == "PRO") {
$percent = $propercent;
} elseif ($info ['memtype'] == "JV Member") {
$percent = $jvpercent;
} elseif ($info ['memtype'] == "SUPER JV") {
$percent = $superjvpercent;
}

$earn = $points * $percent / 100;

mysql_query ( "update members set points=points+" . $earn . " where userid='" . $userid . "'" );
mysql_query ( "INSERT INTO referraltrans VALUES ('id','$userid','Referrer Click Earnings','" . time () . "','$earn points')" );

}

}

}

function pointspool($points) {

global $pointspool;

if ($points) {

$earn = $points * $pointspool / 100;
mysql_query ( "update pool set amount=amount+" . $earn . " where name='points'" );

echo "<font color=blue><b>$earn</b></font> <font color=black>points have been added to the Points Jackpot</font> - ";

}

}



function testemailsetting1 ($testcontact,$testname,$testsubject,$testmessage) {
global $adminemail,$sitename,$adminname,$smtp_host,$smtp_username,$smtp_password,$smtp_port,$smtp_secure,$smtp_enabled;
if($smtp_enabled == 1 ||$smtp_enabled == 2 ||$smtp_enabled == 3 ||$smtp_enabled == 4) {
require_once 'inc/PHPMailer/class.phpmailer.php';
$mail = new PHPMailer;
if($smtp_secure==1) {
$sslsecure='ssl';
}else $sslsecure='tls';
if($smtp_enabled == 1) {
$mail->IsSMTP();
$testsubject='SMTP Test Subject';
$testmessage='SMTP Test Body';
}elseif($smtp_enabled == 2) {
$mail->IsMail();
$testsubject='Mail Test Subject';
$testmessage='Mail Test Body';
}elseif($smtp_enabled == 3) {
$mail->IsSendmail();
$testsubject='Sendmail Test Subject';
$testmessage='Sendmail Test Body';
}elseif($smtp_enabled == 4) {
$mail->IsQmail();
$testsubject='QMail Test Subject';
$testmessage='Qmail Test Body';
}
$mail->Host = $smtp_host;
$mail->Port = $smtp_port;
$mail->SMTPAuth = true;
$mail->Username = $smtp_username;
$mail->Password = $smtp_password;
$mail->SMTPSecure = $sslsecure;
$mail->From = $adminemail;
$mail->FromName = $sitename;
$mail->AddAddress($testcontact,$testname);
$mail->AddReplyTo($adminemail,$adminname);
$mail->WordWrap = 50;
$mail->IsHTML(true);
$subject='Test';
$message='Test Body';
$mail->Subject = $testsubject;
$mail->Body    = $testmessage;
$mail->AltBody = $testmessage;
$now = date('ymdHis').rand(1000,9999);
$mail->Priority = 3;
$mail->Sender=$adminemail;
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: '.$mail->ErrorInfo;
exit;
}
$mail->ClearAddresses();
$mail->ClearAttachments();
}elseif($smtp_enabled == 5) {
$testsubject='Default Mail Test Subject';
$testmessage='Default Test Body';
$now = date('ymdHis').rand(1000,9999);
$headers = "From: $sitename <$adminemail>
";
$headers .= "Return-Path: $sitename <$adminemail>
";
$headers .= "Reply-To: $adminemail
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-type: text/html; charset=iso-8859-1
";
@mail($testcontact,$testsubject,$testmessage,$headers,"-f $adminemail")
or print 'Failed to send email.';
}
}

function moneypool($amount) {

global $moneypool;

if ($amount) {

$earn = $moneypool;
mysql_query ( "update pool set amount=amount+" . $earn . " where name='money'" );
echo "<font color=blue><b>$earn</b></font> <font color=black>cash has been added to the Cash Jackpot</font> - ";
}

}

function buypool($amount) {

global $buypool;

if ($amount) {

$earn = $amount * $moneypool / 100;
mysql_query ( "update pool set amount=amount+" . $earn . " where name='money'" );
mysql_query ( "INSERT INTO transactions VALUES ('id', '" . $userid . "',' Advertising Purchase Pool Bonus ','" . time () . "','$earn cash added money pool')" );

}

}

function ppbuypool($payment_amount) {

global $buypool;

if ($amount) {

$earn = $amount * $moneypool / 100;
mysql_query ( "update pool set amount=amount+" . $earn . " where name='money'" );
mysql_query ( "INSERT INTO transactions VALUES ('id', '" . $userid . "',' Advertising Purchase Pool Bonus ','" . time () . "','$earn cash added money pool')" );

}

}

function upgrade_jv($userid) {

global $jvpoints, $projvcom, $jvjvcom, $superjvjvcom;

$today = date ( 'Y-m-d', strtotime ( "now" ) );

mysql_query ( "UPDATE members SET memtype = 'JV Member', points=points+" . $jvpoints . ", subscribed='$today' WHERE userid = '" . $userid . "'" );
mysql_query ( "INSERT INTO referraltrans VALUES ('id','$userid','Member Upgrade to JV','" . time () . "','Check For Transaction')" );

// Referral commission


$sql = mysql_query ( "SELECT referid FROM members WHERE userid = '" . $userid . "'" );

$referid = mysql_result ( $sql, 0 );

$resultrefer = mysql_query ( "SELECT * FROM members WHERE userid = '" . $referid . "'" );

$line = mysql_fetch_array ( $resultrefer );

$mem = $line ["memtype"];

if ($mem == "SUPER JV") {

$commission = $superjvjvcom;

} elseif ($mem == "JV Member") {

$commission = $jvjvcom;

} elseif ($mem == "PRO") {

$commission = $projvcom;

}

mysql_query ( "UPDATE members SET commission=commission+" . $commission . " WHERE userid='" . $referid . "'" );

if ($commission)
mysql_query ( "INSERT INTO referraltrans VALUES ('id','$referid','Referral Upgrade Commissions $userid','" . time () . "','$$commission')" );

}

function upgrade_superjv($userid) {

global $superjvpoints, $prosupercom, $jvsupercom, $superjv2supercom;

$today = date ( 'Y-m-d', strtotime ( "now" ) );

mysql_query ( "UPDATE members SET memtype = 'SUPER JV', points=points+" . $superjvpoints . ", subscribed='$today' WHERE userid = '" . $userid . "'" );
mysql_query ( "INSERT INTO referraltrans VALUES ('id','$userid','Member Upgrade to SUPER JV','" . time () . "','Check For Transaction')" );

// Referral commission


$sql = mysql_query ( "SELECT referid FROM members WHERE userid = '" . $userid . "'" );

$referid = mysql_result ( $sql, 0 );

$resultrefer = mysql_query ( "SELECT * FROM members WHERE userid = '" . $referid . "'" );

$line = mysql_fetch_array ( $resultrefer );

$mem = $line ["memtype"];

if ($mem == "SUPER JV") {

$commission = $superjv2supercom;

} elseif ($mem == "JV Member") {

$commission = $jvsupercom;

} elseif ($mem == "PRO") {

$commission = $prosupercom;

}

mysql_query ( "UPDATE members SET commission=commission+" . $commission . " WHERE userid='" . $referid . "'" );

if ($commission)
mysql_query ( "INSERT INTO referraltrans VALUES ('id','$referid','Referral Upgrade Commissions $userid','" . time () . "','$$commission')" );

}

function upgrade_jv_exchange($userid) {

global $jvpoints, $projvcom, $jvjvcom, $superjvjvcom;

$today = date ( 'Y-m-d', strtotime ( "now" ) );

mysql_query ( "UPDATE members SET memtype = 'JV Member', points=points+" . $jvpoints . ", subscribed='$today' WHERE userid = '" . $userid . "'" );

}

function upgrade_superjv_exchange($userid) {

global $superjvpoints, $projvcom, $jvjvcom, $superjvjvcom;

$today = date ( 'Y-m-d', strtotime ( "now" ) );

mysql_query ( "UPDATE members SET memtype = 'SUPER JV', points=points+" . $superjvpoints . ", subscribed='$today' WHERE userid = '" . $userid . "'" );

}

function delete_account($userid) {

$sql = mysql_query ( "SELECT * FROM `members` WHERE `userid` = '" . $userid . "'" );

$each = mysql_fetch_array ( $sql );

$info = mysql_query ( "SELECT * FROM members WHERE userid = '" . $each ['referid'] . "'" );

if (@mysql_num_rows ( $info )) {

$ref = mysql_fetch_array ( $info );

if ($ref ['memtype'] == "PRO")
$com = $prorefcom;

else
$com = $jvrefcom;

mysql_query ( "UPDATE members SET commission=commission-" . $com . " WHERE userid = '" . $each ['referid'] . "'" );

mysql_query ( "UPDATE members SET commission=0 WHERE userid = '" . $each ['referid'] . "' AND commission < '0'" );

if ($com)
mysql_query ( "INSERT INTO referraltrans VALUES ('id','" . $each ['referid'] . "','Deleted Referral $userid','" . time () . "','-$$com')" );

}

$query1 = "delete from members where userid='" . $userid . "'";

$result1 = mysql_query ( $query1 );

$query1 = "delete from builder where userid='" . $userid . "'";

$result1 = mysql_query ( $query1 );

$query1 = "delete from surfurls where userid='" . $userid . "'";

$result1 = mysql_query ( $query1 );

$query1 = "delete from support where memberid='" . $userid . "'";

$result1 = mysql_query ( $query1 );

$query1 = "delete from clicks where memberid='" . $userid . "'";

$result1 = mysql_query ( $query1 );

$query2 = "delete from post where userid='" . $userid . "'";

$result2 = mysql_query ( $query2 );

$query2 = "delete from refmail where userid='" . $userid . "'";

$result2 = mysql_query ( $query2 );

$query2 = "delete from tlinks where userid='" . $userid . "'";

$result2 = mysql_query ( $query2 );

$query2 = "delete from solos where userid='" . $userid . "'";

$result2 = mysql_query ( $query2 );

$query2 = "delete from hpsolos where userid='" . $userid . "'";

$result2 = mysql_query ( $query2 );

$query2 = "delete from hpcsolos where userid='" . $userid . "'";

$result2 = mysql_query ( $query2 );

$query2 = "delete from cashsolos where userid='" . $userid . "'";

$result2 = mysql_query ( $query2 );

$query2 = "delete from saved_post where userid='" . $userid . "'";

$result2 = mysql_query ( $query2 );

$query2 = "delete from saved_cashsolos where userid='" . $userid . "'";

$result2 = mysql_query ( $query2 );

$query2 = "delete from saved_html where userid='" . $userid . "'";

$result2 = mysql_query ( $query2 );

$query2 = "delete from saved_solos where userid='" . $userid . "'";

$result2 = mysql_query ( $query2 );

$query3 = "delete from viewed where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from banners where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from buttons where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from drawing where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from urls where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from topnav where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from botnav where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from footerads where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from headlineads where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from hotlinks where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from loginads where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from poolentry where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from tlviews where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from transactions where userid='".$userid."'";
$result3 = mysql_query ($query3);

$query3 = "delete from ptcads where userid='" . $userid . "'";
$result3 = mysql_query ( $query3 );

$query3 = "delete from referraltrans where userid='".$userid."'";
$result3 = mysql_query ( $query3 );

$query3 = "delete from prizetrans where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from urls where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from navlink where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from hheaderads where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$query3 = "delete from hheadlineads where userid='" . $userid . "'";

$result3 = mysql_query ( $query3 );

$sql = "delete from membermail where userid='".$userid."'";
$result = mysql_query ($sql);

$sql = "delete from membermail_viewed where userid='".$userid."'";
$result = mysql_query ($sql);

$sql = "delete from membermail_process where userid='".$userid."'";
$result = mysql_query ($sql);

}
//Begin Downline Builder Code
function getrecommended($referer) {
$selected = "";
$links = array();
if($referer) {
$found = 0;
$user = $referer;

while($found == 0 AND $user != 'admin') {
$sql = mysql_query("SELECT * FROM builder b JOIN members m ON b.userid=m.userid WHERE b.userid='".$user."' AND (b.fav1_url != '' OR b.fav2_url != '' OR b.fav3_url != '')");
if(@mysql_num_rows($sql)) {
$found = 1;
} else {
//Referrer exists?
$sql = mysql_query("SELECT m.referid FROM members m JOIN members r ON m.referid = r.userid WHERE m.userid = '".$user."'");

if(@mysql_num_rows($sql)) {

$user = mysql_result($sql, 0);

} else {
//No more referrers, use default values
$found = 2;
}

}			
}

if($found == 1) {
$favs = mysql_fetch_array($sql);
$fav = array();
if($favs['fav1_title']) $fav[] = array('title'=>$favs['fav1_title'],'url'=>$favs['fav1_url'],'bold'=>$favs['fav1_bold'],'color'=>$favs['fav1_color']);
if($favs['fav2_title']) $fav[] = array('title'=>$favs['fav2_title'],'url'=>$favs['fav2_url'],'bold'=>$favs['fav2_bold'],'color'=>$favs['fav2_color']);
if($favs['fav3_title']) $fav[] = array('title'=>$favs['fav3_title'],'url'=>$favs['fav3_url'],'bold'=>$favs['fav3_bold'],'color'=>$favs['fav3_color']);
$selected = $fav[rand(0,count($fav)-1)];
} else {
$sql = mysql_query("SELECT * FROM builder_fav WHERE url != ''");
if(@mysql_num_rows($sql)) {
$fav = array();
while($favs = mysql_fetch_array($sql)) {
$fav[] = $favs;
}
$selected = $fav[rand(0,count($fav)-1)];
}
}
} else {
$sql = mysql_query("SELECT * FROM builder_fav WHERE url != ''");
if(@mysql_num_rows($sql)) {
$fav = array();
while($favs = mysql_fetch_array($sql)) {
$fav[] = $favs;
}
$selected = $fav[rand(0,count($fav)-1)];
}
}
return $selected;
}
//End Downline Builder Code

function add_adclick($type) {

global $userrecord, $ticketratio;

$userid = $userrecord ['userid'];

if ($type == "text") {

mysql_query ( "UPDATE members SET textad_clicks=textad_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['textad_clicks'] + 1;

} elseif ($type == "surfpages") {

mysql_query ( "UPDATE members SET surf_clicks=surf_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['surf_clicks'] + 1;

} elseif ($type == "solo") {

mysql_query ( "UPDATE members SET solo_clicks=solo_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['solo_clicks'] + 1;

} elseif ($type == "cashsolo") {

mysql_query ( "UPDATE members SET cashsolo_clicks=cashsolo_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['cashsolo_clicks'] + 1;

} elseif ($type == "hpsolo") {

mysql_query ( "UPDATE members SET hpsolo_clicks=hpsolo_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['hpsolo_clicks'] + 1;

} elseif ($type == "hpcsolo") {

mysql_query ( "UPDATE members SET hpcsolo_clicks=hpcsolo_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['hpcsolo_clicks'] + 1;

} elseif ($type == "banner") {

mysql_query ( "UPDATE members SET banner_clicks=banner_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['banner_clicks'] + 1;

} elseif ($type == "button") {

mysql_query ( "UPDATE members SET button_clicks=button_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['button_clicks'] + 1;

} elseif ($type == "hotlink") {

mysql_query ( "UPDATE members SET hotlink_clicks=hotlink_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['hotlink_clicks'] + 1;

} elseif ($type == "htmlad") {

mysql_query ( "UPDATE members SET htmlad_clicks=htmlad_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['htmlad_clicks'] + 1;

} elseif ($type == "navtop") {

mysql_query ( "UPDATE members SET navtop_clicks=navtop_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['navtop_clicks'] + 1;

} elseif ($type == "navbot") {

mysql_query ( "UPDATE members SET navbot_clicks=navbot_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['navbot_clicks'] + 1;

} elseif ($type == "ssolo") {

mysql_query ( "UPDATE members SET supersolo_clicks=supersolo_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['supersolo_clicks'] + 1;

} elseif ($type == "ptc") {

mysql_query ( "UPDATE members SET ptc_clicks=ptc_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['ptc_clicks'] + 1;

} else {

mysql_query ( "UPDATE members SET traffic_clicks=traffic_clicks+1 WHERE userid='" . $userrecord ['userid'] . "'" );

$clicks = $userrecord ['traffic_clicks'] + 1;

}

if ($clicks % $ticketratio == 0) {
mysql_query ( "UPDATE members SET tickets=tickets+1 WHERE userid='" . $userrecord ['userid'] . "'" );
}

$sql = mysql_query ( "SELECT * FROM prizes WHERE type='" . $type . "' AND clicks='" . $clicks . "'" );

if (@mysql_num_rows ( $sql )) {

$offer = mysql_fetch_array ( $sql );

echo "Congratulations! You have won bonus prizes for viewing " . $offer ['clicks'] . " websites!";

$won = "";

if ($offer ['commission']) {

$won .= " $" . $offer ['commission'] . " commissions";

mysql_query ( "UPDATE members SET commission=commission+" . $offer ['commission'] . " WHERE userid='" . $userid . "'" );

mysql_query ( "INSERT INTO prizetrans VALUES ('id', '" . $userid . "','" . $won . "','" . time () . "')" );

}

if ($offer ['points']) {

$won .= " " . $offer ['points'] . " points ";

mysql_query ( "UPDATE members SET points=points+" . $offer ['points'] . " WHERE userid='" . $userid . "'" );

mysql_query ( "INSERT INTO prizetrans VALUES ('id', '" . $userid . "','" . $won . "','" . time () . "')" );

}

if ($offer ['banner_num'] and $offer ['banner_views']) {

$won .= " " . $offer ['banner_num'] . " banner(s) with " . $offer ['banner_views'] . " impressions each";

$count = $offer ['banner_num'];

while ( $count > 0 ) {

mysql_query ( "INSERT INTO `banners` ( `id` , `name` , `bannerurl` , `targeturl` , `userid` , `status` , `shown` , `clicks` , `max` , `added` )VALUES (NULL , '', '', '', '" . $userid . "', '0', '0', '0', '" . $offer ['banner_views'] . "', '0')" );

mysql_query ( "INSERT INTO prizetrans VALUES ('id', '" . $userid . "','" . $won . "','" . time () . "')" );

$count --;

}

}

if ($offer ['button_num'] and $offer ['button_views']) {

$won .= " " . $offer ['button_num'] . " button banner(s) with " . $offer ['button_views'] . " each ";

$count = $offer ['button_num'];

while ( $count > 0 ) {

mysql_query ( "INSERT INTO `buttons` ( `id` , `name` , `bannerurl` , `targeturl` , `userid` , `status` , `shown` , `clicks` , `max` , `added` )VALUES (NULL , '', '', '', '" . $userid . "', '0', '0', '0', '" . $offer ['button_views'] . "', '0')" );

mysql_query ( "INSERT INTO prizetrans VALUES ('id', '" . $userid . "','" . $won . "','" . time () . "')" );
$count --;

}

}
if ($offer ['traffic_num'] and $offer ['traffic_views']) {

$won .= " " . $offer ['traffic_num'] . " traffic link(s) with " . $offer ['traffic_views'] . " views per link";

$count = $offer ['traffic_num'];

while ( $count > 0 ) {

mysql_query ( "insert into tlinks (userid,paid) values('$userid','" . $offer ['traffic_views'] . "')" );

mysql_query ( "INSERT INTO prizetrans VALUES ('id', '" . $userid . "','" . $won . "','" . time () . "')" );

$count --;

}

}

if ($offer ['ptc_num'] and $offer ['ptc_views']) {

$won .= " " . $offer ['ptc_num'] . " paid to click link(s) with " . $offer ['ptc_views'] . " views per link";

$count = $offer ['ptc_num'];

while ( $count > 0 ) {

mysql_query ( "insert into ptcads (userid,paid) values('$userid','" . $offer ['ptc_views'] . "')" );

mysql_query ( "INSERT INTO prizetrans VALUES ('id', '" . $userid . "','" . $won . "','" . time () . "')" );

$count --;

}

}

if ($offer ['solo_num']) {

$won .= " " . $offer ['solo_num'] . " solo ad(s) ";

$count = $offer ['solo_num'];

while ( $count > 0 ) {

mysql_query ( "INSERT INTO `solos` (`id` ,`userid` ,`approved` ,`subject` ,`adbody` ,`sent` ,`added`) VALUES (NULL , '" . $userid . "', '0', '', '', '0', '0')" );

mysql_query ( "INSERT INTO prizetrans VALUES ('id', '" . $userid . "','" . $won . "','" . time () . "')" );

$count --;

}

}

if ($offer ['login_num'] and $offer ['login_views']) {

$won .= " " . $offer ['login_num'] . " login ad(s) with " . $offer ['login_views'] . " impressions each";

$count = $offer ['login_num'];
while ( $count > 0 ) {

mysql_query ( "insert into loginads (userid,max) values('$userid','" . $offer ['login_views'] . "')" );

mysql_query ( "INSERT INTO prizetrans VALUES ('id', '" . $userid . "','" . $won . "','" . time () . "')" );
$count --;

}

}
if ($offer ['hotlink_num'] and $offer ['hotlink_views']) {

$won .= " " . $offer ['hotlink_num'] . " hotlink ad(s) with " . $offer ['hotlink_views'] . " views per link";

$count = $offer ['hotlink_num'];

while ( $count > 0 ) {

mysql_query ( "INSERT INTO hotlinks (userid,max,purchase) values('$userid','" . $offer ['hotlink_views'] . "','" . time () . "')" );

mysql_query ( "INSERT INTO prizetrans VALUES ('id', '" . $userid . "','" . $won . "','" . time () . "')" );

$count --;

}

}

if ($offer ['topnav_num']) {

$won .= " " . $offer ['topnav_num'] . " top navigation link(s) ";

$count = $offer ['topnav_num'];

while ( $count > 0 ) {

mysql_query ( "INSERT INTO `topnav` ( `userid` , `date`) VALUES ('" . $userid . "', '" . time () . "')" );

mysql_query ( "INSERT INTO prizetrans VALUES ('id', '" . $userid . "','" . $won . "','" . time () . "')" );

$count --;

}

}

if ($offer ['botnav_num']) {

$won .= " " . $offer ['botnav_num'] . " bottom navigation link(s) ";

$count = $offer ['botnav_num'];

while ( $count > 0 ) {

mysql_query ( "INSERT INTO `botnav` ( `userid` , `date`) VALUES ('" . $userid . "', '" . time () . "')" );

mysql_query ( "INSERT INTO prizetrans VALUES ('id', '" . $userid . "','" . $won . "','" . time () . "')" );

$count --;

}

}

mysql_query ( "INSERT INTO prizes_won SET userid='$userid', won='$won'" );

echo $won;

echo "<br>";

} else {

if ($type == "text") {
echo "You have viewed $clicks Text Ads today. Awesome!";
} elseif ($type == "surfpages") {
echo "You have viewed " . $clicks . " Surf site(s) today.";
} elseif ($type == "htmlad") {
echo "You have viewed $clicks HTML Ads today. Good work!";
} elseif ($type == "solo") {
echo "You have viewed $clicks Solo Ads today. Thank you!";
} elseif ($type == "cashsolo") {

echo "You have viewed $clicks Cash Solos today. Excellent!";

} elseif ($type == "banner") {
echo "You have viewed $clicks Banner Ads today.";
} elseif ($type == "button") {
echo "You have viewed $clicks Button Banner ads today. Thanks!";
} elseif ($type == "hotlink") {
echo "You have viewed $clicks Hotlinks today. Thanks!";

} elseif ($type == "navtop") {

echo "You have viewed $clicks Top Navigation Links today. Thanks!";

} elseif ($type == "navbot") {

echo "You have viewed $clicks Bottom Navigation Links today. Thanks!";

} elseif ($type == "psolo") {

echo "You have viewed $clicks Power Solos today.";

} elseif ($type == "hpsolo") {

echo "You have viewed $clicks High Priority Solos today. Thank You!";

} elseif ($type == "hpcsolo") {

echo "You have viewed $clicks High Priority Cash Solos today. Thank You!";

} elseif ($type == "ptc") {
echo "You have viewed $clicks PTC Links today. Super!";
} else {
echo "You have viewed $clicks Traffic Links today. Great Job!";

}

echo "<br>";

}

}

extract ( $_REQUEST );

if ($_SERVER ['HTTP_REFERER']) {
$domain2 = parse_url ( $_SERVER ['HTTP_REFERER'] );
$domain3 = str_replace ( "www.", "", $domain2 ['host'] );

if ($domain3 == "textadsubmitter.com") {

echo "<font size=3 face='$fonttype' color='$fontcolour'><p><b><center>Error.</p><b></center></font>";
exit ();
}
}
?>