<?php

function removecronjob($id) {
foreach($id as $itemid) {
$ssq3 = "delete from cron_jobs where id='".$itemid."'";
$ssr3 = mysql_query($ssq3);
}
}
function addcronjob($crontitle,$croncommand) {
mysql_query("INSERT INTO cron_jobs VALUES ('id','".$crontitle."','".$croncommand."')");
}
function add_failedpayments () {
global $fonttype,$fontcolour,$basecolour;
preview();
if ($_GET['pageid'] == 'paymenterror') {
;echo '<center><H2>Complete Failed Payments</H2></center>
<p><a href="payment_logs.php">Payment Transactions</a></p>
<table>
<tr>
<td valign="top" align="center"><br><br> 
';
echo "<font size=2 face='$fonttype' color='#000000'><p><b><center>";
if($_POST['action'] == 'ADDOTO') {
$processor = $_POST['processor'];
$item = $_POST['item'];
$userid = $_POST['userid'];
$payment_amount = $_POST['payment_amount'];
$check=checkuser ($userid);
if($check) {
print $check;
echo '</td></tr></table>';
include '/footer.php';
exit;
}
if (empty($processor)) {
echo "<font size=3 face='$fonttype' color='$fontcolour'><p><b><center>Error! Payment processor wasn't selected. Please click your browsers back button.</p><b></center></font>";
echo '</td></tr></table>';
include '/footer.php';
exit();
}
if (empty($item)) {
echo "<font size=3 face='$fonttype' color='$fontcolour'><p><b><center>Error! Item wasn't selected. Please click your browsers back button.</p><b></center></font>";
echo '</td></tr></table>';
include '/footer.php';
exit();
}
if (empty($userid)) {
echo "<font size=3 face='$fonttype' color='$fontcolour'><p><b><center>Error! Userid field is empty. Please click your browsers back button.</p><b></center></font>";
echo '</td></tr></table>';
include '/footer.php';
exit();
}
if (empty($payment_amount)) {
echo "<font size=3 face='$fonttype' color='$fontcolour'><p><b><center>Error! Payment amount is empty. Please click your browsers back button.</p><b></center></font>";
echo '</td></tr></table>';
include '/footer.php';
exit();
}
$query = "select * from members where userid='".$userid."'";
$result = mysql_query ($query)or die ('Query failed');
$user = mysql_fetch_array($result);
add_sale ($payment_amount);
add_income ($payment_amount);
if($processor == 'Paypal'||$processor == 'Payza') {
payment_ipn_log($processor,'Manual',$payment_amount,'USD','Manual','Manual','Manual',$userid,"$item",'0');
mysql_query("INSERT INTO transactions VALUES ('id','".$userid."','Manual $processor $item','".time()."','$payment_amount\$')");
mysql_query("INSERT INTO account_ledger VALUES ('id','".$userid."','PURCHASE: $item','".time()."','$payment_amount')");
}
if($item == 'OFFER 1') {
$table='offer';
$pdoto=1;
}elseif($item == 'OFFER 2') {
$table='offer';
$pdoto=2;
}elseif($item == 'OFFER 3') {
$table='offer';
$pdoto=3;
}elseif($item == 'OTO 1') {
$table='oto';
$pdoto=1;
}elseif($item == 'OTO 2') {
$table='oto';
$pdoto=2;
}elseif($item == 'OTO 3') {
$table='oto';
$pdoto=3;
}
if($item == 'OFFER 1'||$item == 'OFFER 2'||$item == 'OFFER 3'||$item == 'OTO 1'||$item == 'OTO 3'||$item == 'OTO 3') {
$sql = mysql_query("SELECT * FROM $table WHERE id='".$pdoto."' LIMIT 1");
$oto = mysql_fetch_array($sql);
add_commission($userid,$oto['pdcommission'],$user['referid'],"$table $pdoto");
if($oto['points']) mysql_query('UPDATE members SET points=points+'.$oto['points']." WHERE userid='".$userid."'");
if($oto['banner_num'] AND $oto['banner_views']) {
$count = $oto['banner_num'];
while($count >0) {
mysql_query("INSERT INTO `banners` (`userid`,`max` )VALUES ('".$userid."','".$oto['banner_views']."')");
$count--;
}
}if($oto['button_num'] AND $oto['button_views']) {
$count = $oto['button_num'];
while($count >0) {
mysql_query("INSERT INTO `buttons` (`userid`,`max`)VALUES ('".$userid."','".$oto['button_views']."')");
$count--;
}
}if($oto['text_num'] AND $oto['text_views']) {
$count = $oto['text_num'];
while($count >0) {
mysql_query("insert into texts (userid,paid) values('$userid','".$oto['text_views']."')");
$count--;
}
}if($oto['upgrade']=='1') {
if($user['memtype'] == 'PRO'||$user['memtype'] == 'JV Member') {
upgrade (1,1,$userid);
}
}if($oto['upgrade']=='2') {
upgrade (2,1,$userid);
}
}elseif ($item == 'JV Member Upgrade') {
upgrade (1,0,$userid);
}elseif ($item == 'SUPER JV Upgrade') {
upgrade (2,0,$userid);
}
echo '<center>The transaction has been added!</center>';
}
;echo '
<p>
<form method="POST">
<input type="hidden" name="action" value="ADDOTO">
<table border=0><tr><td>
<table border=0 cellpadding=3 cellspacing=0>
<tr><td width=160 align=right>Payment Processor:</td>
<td><select name="processor">
<option></option>
<option>Paypal</option>
<option>Payza</option>
</select>
</td></tr>
<tr><td width=160 align=right>Item:</td>
<td><select name="item">
<option></option>
<option>OFFER 1</option>
<option>OFFER 2</option>
<option>OFFER 3</option>
<option>OTO 1</option>
<option>OTO 2</option>
<option>OTO 3</option>
<option>JV Member Upgrade</option>
<option>SUPER JV Upgrade</option> 
</select>
</td></tr>
<tr><td width=160 align=right>Userid:</td><td><input type="text" name="userid"></td></tr>
<tr><td width=160 align=right>Payment Amount: $</td><td><input type="text" name="payment_amount"></td></tr>
<tr><td>&nbsp;</td><td><input type="submit" value="Add OTO Sale"></td></tr></table>
</td></tr></table>
</form>
</p>
</td></tr></table>
';
}else {
;echo '<center><H2>Payment Transactions</H2></center>
<p><a href=payment_logs.php?pageid=paymenterror>Complete Failed Payments</a></p>
<table width=100% align=center>
<tr>
<td valign="top" align="center"><br><br> 
';
echo "<font size=2 face='$fonttype' color='#000000'><p><b><center>";
if($_POST['action'] == 'Delete') {
$id = $_REQUEST['id'];
foreach($id as $each) {
mysql_query ('delete from payment_ipn_log where payment_id='.$each);
}
echo '<center>The transaction has been deleted!</center>';
}
$query = 'select * from payment_ipn_log ORDER by payment_time DESC';
$result = mysql_query ($query) or die ('Query failed');
;echo ' <form method=POST name=paytrans>
<center>
<table width=90% border=0 cellpadding=2 cellspacing=2 bgcolor="#000000">
<tr>
<td bgcolor="#000000"><center><font size=2 face="';echo $fonttype;;echo '" color="#FFFFFF"></font></center></td>
<td bgcolor="#000000"><center><font size=2 face="';echo $fonttype;;echo '" color="#FFFFFF">ID</font></center></td>
<td bgcolor="#000000"><center><font size=2 face="';echo $fonttype;;echo '" color="#FFFFFF">Userid/Payer</font></center></td>
<td bgcolor="#000000"><center><font size=2 face="';echo $fonttype;;echo '" color="#FFFFFF">Transaction/Status</font></center></td>
<td bgcolor="#000000"><center><font size=2 face="';echo $fonttype;;echo '" color="#FFFFFF">Receiver/Txn_id</font></center></td>
<td bgcolor="#000000"><center><font size=2 face="';echo $fonttype;;echo '" color="#FFFFFF">Date</font></center></td>
<td bgcolor="#000000"><center><font size=2 face="';echo $fonttype;;echo '" color="#FFFFFF">Amount</font></center></td>

</tr>
';
while ($line = mysql_fetch_array($result)) {
$id = $line['payment_id'];
$type = $line['type'];
$userid = $line['userid'];
$payer = $line['payer_email'];
$item = $line['item'];
$payment_status = $line['payment_status'];
$receiver_email = $line['receiver_email'];
$txn_id = $line['txn_id'];
$payment_time = $line['payment_time'];
$payment_amount = $line['payment_amount'];
;echo '<tr>
<td bgcolor="';echo $basecolour;;echo '"><input type="checkbox" name="id[]" value="';echo $id;;echo '"></td>
<td bgcolor="#FFFFCC"><center><font size=2 face="';echo $fonttype;;echo '" color="#000000">';echo $id;;echo '</font></center></td>
<td bgcolor="#FFFFCC"><center><font size=2 face="';echo $fonttype;;echo '" color="#000000">';echo $userid;;echo '<br>';echo $payer;;echo '</font></center></td>
<td bgcolor="#FFFFCC"><center><font size=2 face="';echo $fonttype;;echo '" color="#000000">';echo $type;;echo '<br>';echo $item;;echo '<br>';echo $payment_status;;echo '</font></center></td>        
<td bgcolor="#FFFFCC"><center><font size=2 face="';echo $fonttype;;echo '" color="#000000">';echo $receiver_email;;echo '<br>';echo $txn_id;;echo '</font></center></td>
<td bgcolor="#FFFFCC"><center><font size=2 face="';echo $fonttype;;echo '" color="#000000">';echo $payment_time;;echo '</font></center></td>
<td bgcolor="#FFFFCC"><center><font size=2 face="';echo $fonttype;;echo '" color="#000000">';echo $payment_amount;;echo '</font></center></td>
</td></tr> ';
}
echo '</table><input type="button" onClick="return Inverse(document.paytrans);" value="Inverse"><input type="submit" name="action" value="Delete"></form></center>';
echo '</td></tr></table>';
echo '</td></tr></table>';
}
}
function ad_ledger () {
global $fonttype,$fontcolour;
echo '<H2 align=center>Admin Ad Ledger</H2>';
$query = 'select * from ad_ledger ORDER by date DESC';
$result = mysql_query ($query) or die ('Query failed');
;echo ' 
<center><table width=90% border=0 cellpadding=2 cellspacing=2 bgcolor="#000000">
<tr>
<td width=30% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Userid</font></center></td>
<td width=40% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Transaction</font></center></td>
<td width=15% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Date</font></center></td>
<td width=15% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Amount</font></center></td>
</tr>
';
while ($line = mysql_fetch_array($result)) {
$id = $line['id'];
$userid = $line['userid'];
$action = $line['action'];
$sqltimestamp = $line['date'];
$quantity = $line['quantity'];
;echo '             <tr>
<td bgcolor="#FFFFCC"><div align=left><font size=2 color="#000000">';echo $userid;;echo '</font></div></td>        
<td bgcolor="#FFFFCC"><div align=left><font size=2 color="#000000">';echo $action;;echo '</font></div></td>        
<td bgcolor="#FFFFCC"><center><font size=2 color="#000000">';echo date ('Y-m-d H:i:s',$sqltimestamp);;echo '</font></center></td>
<td bgcolor="#FFFFCC"><center><font size=2 color="#000000">';echo $quantity;;echo '</font></center></td>    
</tr>
';
}
echo '</table></center>';
echo "<font size=4 face='$fonttype' color='$fontcolour'><p>Search Logs<center>";;echo '	        <center>';
if($_POST['action'] == 'search') {
$userid = $_POST['userid'];
;echo '	<table width=90% border=0 cellpadding=2 cellspacing=2 bgcolor="#000000">
<tr>
<td width=30% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Userid</font></center></td>
<td width=40% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Transaction</font></center></td>
<td width=15% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Date</font></center></td>
<td width=15% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Amount</font></center></td>
</tr>
';
$query = "select * from ad_ledger where userid='$userid' ORDER BY id DESC";
$result = mysql_query ($query)
or die ('Search failed');
$num_rows = mysql_num_rows($result);
if($num_rows==0) {
echo '<div align=center>NO RESULTS FOUND</div>';
}
while ($line = mysql_fetch_array($result)) {
$id = $line['id'];
$userid = $line['userid'];
$action = $line['action'];
$sqltimestamp = $line['date'];
$quantity = $line['quantity'];
;echo '  	     <tr>
<td bgcolor="#FFFFCC"><div align=left><font size=2 color="#000000">';echo $userid;;echo '</font></div></td>        
<td bgcolor="#FFFFCC"><div align=left><font size=2 color="#000000">';echo $action;;echo '</font></div></td>        
<td bgcolor="#FFFFCC"><center><font size=2 color="#000000">';echo date ('Y-m-d H:i:s',$sqltimestamp);;echo '</font></center></td>
<td bgcolor="#FFFFCC"><center><font size=2 color="#000000">';echo $quantity;;echo '</font></center></td>    
</tr>
';
}
;echo '	 </center>
</td>
</tr>
</table>
';
}
;echo '
<form method="POST">
<font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">
Userid:<br><input type="text" name="userid" maxLength="50" size="40" value=""><br>
<input type="hidden" name="action" value="search">
<br><input type="submit" value="Search">
</form>
</font>
</center>
</td>
</tr>
</table>
';
}
function account_ledger () {
global $fonttype,$fontcolour;
echo '<H2 align=center>Member Account Ledger</H2>';
$query = 'select * from account_ledger ORDER by date DESC';
$result = mysql_query ($query) or die ('Query failed');
;echo ' 
<center><table width=90% border=0 cellpadding=2 cellspacing=2 bgcolor="#000000">
<tr>
<td width=30% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Userid</font></center></td>
<td width=40% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Transaction</font></center></td>
<td width=15% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Date</font></center></td>
<td width=15% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Amount</font></center></td>
</tr>
';
while ($line = mysql_fetch_array($result)) {
$id = $line['id'];
$userid = $line['userid'];
$action = $line['action'];
$sqltimestamp = $line['date'];
$quantity = $line['quantity'];
;echo '             <tr>
<td bgcolor="#FFFFCC"><div align=left><font size=2 color="#000000">';echo $userid;;echo '</font></div></td>        
<td bgcolor="#FFFFCC"><div align=left><font size=2 color="#000000">';echo $action;;echo '</font></div></td>        
<td bgcolor="#FFFFCC"><center><font size=2 color="#000000">';echo date ('Y-m-d H:i:s',$sqltimestamp);;echo '</font></center></td>
<td bgcolor="#FFFFCC"><center><font size=2 color="#000000">';echo $quantity;;echo '</font></center></td>    
</tr>
';
}
echo '</table></center>';
echo "<font size=4 face='$fonttype' color='$fontcolour'><p>Search Logs<center>";;echo '	        <center>';
if($_POST['action'] == 'search') {
$userid = $_POST['userid'];
;echo '	<table width=90% border=0 cellpadding=2 cellspacing=2>
<tr>
<td width=30% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Userid</font></center></td>
<td width=40% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Transaction</font></center></td>
<td width=15% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Date</font></center></td>
<td width=15% bgcolor="#CCCCCC"><center><font size=2 color="#000000">Amount</font></center></td>
</tr>
';
$query = "select * from account_ledger where userid='$userid' ORDER BY id DESC";
$result = mysql_query ($query)
or die ('Search failed');
$num_rows = mysql_num_rows($result);
if($num_rows==0) {
echo '<div align=center>NO RESULTS FOUND</div>';
}
while ($line = mysql_fetch_array($result)) {
$id = $line['id'];
$userid = $line['userid'];
$action = $line['action'];
$sqltimestamp = $line['date'];
$quantity = $line['quantity'];
;echo '  	     <tr>
<td bgcolor="#FFFFCC"><div align=left><font size=2 color="#000000">';echo $userid;;echo '</font></div></td>        
<td bgcolor="#FFFFCC"><div align=left><font size=2 color="#000000">';echo $action;;echo '</font></div></td>        
<td bgcolor="#FFFFCC"><center><font size=2 color="#000000">';echo date ('Y-m-d H:i:s',$sqltimestamp);;echo '</font></center></td>
<td bgcolor="#FFFFCC"><center><font size=2 color="#000000">';echo $quantity;;echo '</font></center></td>    
</tr>
';
}
;echo '	 </center>
</td>
</tr>
</table>
';
}
;echo '
<form method="POST">
<font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">
Userid:<br><input type="text" name="userid" maxLength="50" size="40" value=""><br>
<input type="hidden" name="action" value="search">
<br><input type="submit" value="Search">
</form>
</font>
</center>
</td>
</tr>
</table>
';
}
function lifetimestats () {
global $nav_bg;
expandable();
$query = 'SELECT * FROM `lifetimeadstats`';
$result = mysql_query ($query)
or die ('Query failed');
$numrows = @ mysql_num_rows($result);
;echo '            <table align=center width=614 bgcolor=#000000 border=0 cellpadding=2 cellspacing=1>
<tr>
<td colspan=3 bgcolor="';echo $nav_bg;;echo '"> 
<div style="text-align:left;width:75%;font-size:12px;float:left;font-weight: bold;">View Lifetime Stats  [<a title="show/hide" id="als_link" href="javascript: void(0);" onclick="toggle(this, \'als\');"  style="text-decoration: strong; color: #000000; ">-</a>]</div>
</td>
</tr>
</table>
';echo openchart('als');;echo '            <table align=center width=600 bgcolor=#000000 border=0 cellpadding=1 cellspacing=1>
<tr>
<td bgcolor="#FFFFFF">
';echo "<div id=\"displayals\">";;echo '';
echo '<H2 align=center>Total Lifetime Ad Stats</H2>';
$TotQuery = 'SELECT SUM(banner_clicks+button_clicks+textlink_clicks+adminsites+admin_clicks+listmail_clicks+creditmail_clicks) as total_clicks 
FROM lifetimeadstats';
$sRow = mysql_fetch_array(mysql_query($TotQuery));
$total = $sRow['total_clicks'];
$TotSentQuery = 'SELECT SUM(banner_sent+button_sent+textlink_sent+adminsites+admin_sent+listmail_sent+creditmail_sent+refmail_sent) as total_sent 
FROM lifetimeadstats';
$sentRow = mysql_fetch_array(mysql_query($TotSentQuery));
$totalsent = $sentRow['total_sent'];
;echo '<div align=center><b>You have had <font color=RED>';echo number_format($total);;echo '</font> total ad clicks and <font color=RED>';echo number_format($totalsent);;echo '</font> ads delivered.</b></div>

<table align=center width=350 border=0 bgcolor=#000000 cellpadding=1 cellspacing=1>

';
while ($line = mysql_fetch_array($result)) {;echo '<tr><td valign="top" align="center"  bgcolor="E6E6EE"><font size=2 face="arial" color="#000000">AD TYPE</font></td><td valign="top" align="center" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000"># OF Clicks</font></td><td valign="top" align="center" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000"># OF Sent</font></td></tr>
<tr><td valign="top" align="left"  bgcolor="E6E6EE"><font size=2 face="arial" color="#000000">ADMIN</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['admin_clicks']);;echo '</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['admin_sent']);;echo '</font></td></tr>
<tr><td valign="top" align="left"  bgcolor="E6E6EE"><font size=2 face="arial" color="#000000">BANNER</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['banner_clicks']);;echo '</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['banner_sent']);;echo '</font></td></tr>
<tr><td valign="top" align="left"  bgcolor="E6E6EE"><font size=2 face="arial" color="#000000">BUTTON BANNER</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['button_clicks']);;echo '</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['button_sent']);;echo '</font></td></tr>
<tr><td valign="top" align="left"  bgcolor="E6E6EE"><font size=2 face="arial" color="#000000">TEXTLINK</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['textlink_clicks']);;echo '</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['textlink_sent']);;echo '</font></td></tr>
<tr><td valign="top" align="left"  bgcolor="E6E6EE"><font size=2 face="arial" color="#000000">ADMIN SITES</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['adminsites']);;echo '</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['adminsites']);;echo '</font></td></tr>
<tr><td valign="top" align="left"  bgcolor="E6E6EE"><font size=2 face="arial" color="#000000">REF MAIL</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">N/A</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['refmail_sent']);;echo '</font></td></tr>
<tr><td valign="top" align="left"  bgcolor="E6E6EE"><font size=2 face="arial" color="#000000">LIST MAIL</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['listmail_clicks']);;echo '</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['listmail_sent']);;echo '</font></td></tr>
<tr><td valign="top" align="left"  bgcolor="E6E6EE"><font size=2 face="arial" color="#000000">CREDIT MAIL</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['creditmail_clicks']);;echo '</font></td><td valign="top" align="right" bgcolor="#CCCCCC"><font size=2 face="arial" color="#000000">';echo number_format($line['creditmail_sent']);;echo '</font></td></tr>
';
}
echo '</table>';
echo '<br><br></font></td></tr></table></div></div>';
echo chartclose('als');
}
function adminsentstats () {
global $nav_bg;
expandable();
;echo '            <table align=center width=614 bgcolor=#000000 border=0 cellpadding=2 cellspacing=1>
<tr>
<td colspan=3 bgcolor="';echo $nav_bg;;echo '"> 
<div style="text-align:left;width:75%;font-size:12px;float:left;font-weight: bold;">View Ads Sent  [<a title="show/hide" id="ass_link" href="javascript: void(0);" onclick="toggle(this, \'ass\');"  style="text-decoration: strong; color: #000000; ">-</a>]</div>
</td>
</tr>
</table>
';echo openchart('ass');;echo '            <table align=center width=600 bgcolor=#000000 border=0 cellpadding=1 cellspacing=1>
<tr>
<td bgcolor="#FFFFFF">
';echo "<div id=\"displayass\">";;echo '    <p align=left>     
';
$today_start = mktime(0,0,0,date('m'),date('d'),date('Y'));
$today_end = mktime(23,59,59,date('m'),date('d'),date('Y'));
$refmail_sent="SELECT * FROM refmail WHERE timestamp >= $today_start AND timestamp <= $today_end";
$resultrefmail_sent = mysql_query ($refmail_sent)or die ('Failed5');
$num_refmail_sent = @ mysql_num_rows($resultrefmail_sent);
$listmail_sent="SELECT * FROM listmailer WHERE timestamp >= $today_start AND timestamp <= $today_end";
$resultlistmail_sent = mysql_query ($listmail_sent)or die ('Failed5');
$num_listmail_sent = @ mysql_num_rows($resultlistmail_sent);
$listsql = "SELECT SUM(sentto) as total_sentto from listmailer WHERE timestamp >= $today_start AND timestamp <= $today_end";
$listrow = mysql_fetch_array(mysql_query($listsql));
$listcount = $listrow[total_sentto];
if($listcount==NULL) $listcount=0;
$cmail_sent="SELECT * FROM membermail WHERE timestamp >= $today_start AND timestamp <= $today_end";
$resultcmail_sent = mysql_query ($cmail_sent)or die ('Failed5');
$num_cmail_sent = @ mysql_num_rows($resultcmail_sent);
$cmailsql = "SELECT SUM(sentto) as total_sentto from membermail WHERE timestamp >= $today_start AND timestamp <= $today_end";
$cmailrow = mysql_fetch_array(mysql_query($cmailsql));
$cmailcount = $cmailrow[total_sentto];
if($cmailcount==NULL) $cmailcount=0;
;echo '     

Ref Mail sent today: ';echo $num_refmail_sent;;echo '<br>
List Mail sent today: ';echo $num_listmail_sent;;echo ' Members Mailed: ';echo $listcount;;echo '<br>
Credit Mail sent today: ';echo $num_cmail_sent;;echo ' Members Mailed: ';echo $cmailcount;;echo '<br>
';
echo '</font></td></tr></table></div></div>';
echo chartclose('ass');
}
function adminstats () {
$query = 'SELECT * FROM totalclickstats';
$result = mysql_query ($query)
or print '';
while ($line = mysql_fetch_array($result)) {
$daily = $line['daily'];
$weekly = $line['weekly'];
$monthly = $line['monthly'];
$yearly = $line['yearly'];
$lifetime = $line['lifetime'];
}
$getdelivered = mysql_query('Select delivered from `lifetimeadstats`');
$delivered = mysql_result($getdelivered,0,'delivered');
;echo '<font size="1">
<b>Today Clicks: <font color=RED>';echo number_format($daily);;echo '</font></b>  &nbsp;&nbsp;
<b>Weekly Clicks: <font color=RED>';echo number_format($weekly);;echo '</font></b> &nbsp;&nbsp;
<b>Monthly Clicks: <font color=RED>';echo number_format($monthly);;echo '</font></b> <br>
<b>Yearly Clicks: <font color=RED>';echo number_format($yearly);;echo '</font></b> &nbsp;&nbsp;
<b>Lifetime Clicks: <font color=RED>';echo number_format($lifetime);;echo '</font></b> &nbsp;&nbsp;
<b>Lifetime Impressions Delivered: <font color=RED>';echo number_format($delivered);;echo '</font></b>
</font>
';
}
function viewads ($type) {
if($type == 'Credit Mail') {
viewcreditmail ();
}
if($type == '468X60 Banners') {
viewbanners ();
}
if($type == '125X125 Banners') {
viewbuttons ();
}
if($type == 'Text Links') {
viewtexts ();
}
}
function deleteads ($id,$xid) {
global $fonttype,$fontcolour;
if (empty ( $id )) {
echo "<font size=3 face='$fonttype' color='$fontcolour'><p><b><center>You must check at least one box next to an ad.</p><b></center></font>";
header('refresh: 1; url=approveads.php');
exit ();
}
foreach($id as $item){
$pieces = explode(',',$item);
$radid=$pieces[0];
$radtype=$pieces[1];
if($radtype=='banner') {
mysql_query ('update banners set added=0 where id='.$radid);
}elseif($radtype=='button') {
mysql_query ('update buttons set added=0 where id='.$radid);
}elseif($radtype=='texts') {
mysql_query ('update texts set added=0 where id='.$radid);
}elseif($radtype=='avatar') {
$sr1 = "select image from members WHERE id='".$radid."'";
$sr2 = mysql_query($sr1) or die(mysql_error());
while($srow = mysql_fetch_array($sr2))
{
$imagetodelete=$srow['image'];
$filename = "../img/$imagetodelete";
unlink($filename);
$ssq2 = "update members set image='', image_approved=0 where id='".$radid."'";
$ssr2 = mysql_query($ssq2);
}
}elseif($radtype=='sitereports') {
if($xid!='') {
foreach($xid as $xitem){
}
}
$sr1 = "select * from site_reports WHERE id='".$radid."'";
$sr2 = mysql_query($sr1) or die(mysql_error());
while($srow = mysql_fetch_array($sr2))
{
$ssq3 = "delete from site_reports where id='".$srow['id']."'";
$ssr3 = mysql_query($ssq3);
}
}
}
echo "<p><center><span style=\"background-color: yellow;\">The ads have been sent back to the member.</span></p></center>";
header('refresh: 2; url=approveads.php');
}
function approveads ($id) {
global $fonttype,$fontcolour;
if (empty ( $id )) {
echo "<font size=3 face='$fonttype' color='$fontcolour'><p><b><center>You must check at least one box next to an ad.</p><b></center></font>";
header('refresh: 1; url=approveads.php');
exit ();
}
foreach($id as $item){
$pieces = explode(',',$item);
$radid=$pieces[0];
$radtype=$pieces[1];
$string = random_string(10);
if($radtype=='banner') {
mysql_query ("update banners set status=1, num='".$string."' where id=".$radid);
}elseif($radtype=='button') {
mysql_query ("update buttons set status=1, num='".$string."' where id=".$radid);
}elseif($radtype=='texts') {
mysql_query ("update texts set approved=1, num='".$string."' where id=".$radid);
}elseif($radtype=='avatar') {
mysql_query ('update members set image_approved=1 where id='.$radid);
}
}
echo "<p><center><span style=\"background-color: yellow;\">The ads have been approved.</span></p></center>";
header('refresh: 2; url=approveads.php');
}
function editads ($id,$type) {
$id = $_REQUEST['id'];
$done = $_POST['done'];
$id = $_POST['id'];
$userid = $_POST['userid'];
$added = $_POST['added'];
$shown = $_POST['shown'];
$approved = $_POST['approved'];
$max = $_POST['max'];
$bannerurl = $_POST['bannerurl'];
$targeturl = $_POST['targeturl'];
$sent = $_POST['sent'];
$adbody = $_POST['adbody'];
$subject = $_POST['subject'];
$url = $_POST['url'];
$points2 = $_POST['points2'];
$position = $_POST['position'];
$max = $_POST['max'];
if($type==banner) {
if ($done == 'YES') {
if (empty($targeturl)){
;echo '<center><p>No \'targeturl\' entered. Click <a href=approveads.php>here</a> to go back<p></center> ';
include '/footer.php';
exit;
}
if (empty($bannerurl)){
;echo '<center><p>No \'bannerurl\' entered. Click <a href=approveads.php>here</a> to go back<p></center> ';
include '/footer.php';
exit;
}
$query = "update banners set status='$approved', bannerurl='$bannerurl', url='$targeturl'  where id=".$id;
$result = mysql_query ($query) or die ('Query failed');
echo "<p align=\"center\"><span style=\"background-color: #FFFF00; color: #FF0000;font-size: 12px; width: 234px;\">468X60 Banner has been edited.</span></p>";
header('refresh: 1; url=approveads.php');
}
else {
$id = $_GET['id'];
$query2 = "select * from banners where id='".$id."'  LIMIT 1";
$result2 = mysql_query ($query2) or die ('Query2 failed');
$line = mysql_fetch_array($result2);
$id = $line['id'];
$bannerurl = $line['bannerurl'];
$targeturl = $line['url'];
;echo '
<center><H2>Edit Banner</H2><br>
<form method="POST">
<img src="';echo $bannerurl;;echo '"><br><br>
Target Url:<br>
<input type="text" name="targeturl" size="50" value="';echo $targeturl;;echo '"><br><br>
Banner Url:<br>
<input type="text" name="bannerurl" size="50" value="';echo $bannerurl;;echo '"><br><br>
<input type="hidden" name="approved" maxsize="1" value=0><br><br>
<input type="hidden" name="id" value="';echo $id;;echo '">
<input type="hidden" name="done" value="YES">
<input type="submit" value="Save">
</form></center>

';
}
}
if($type==button) {
if ($done == 'YES') {
if (empty($targeturl)){
;echo '<center><p>No \'targeturl\' entered. Click <a href=approveads.php>here</a> to go back<p></center> ';
include '/footer.php';
exit;
}
if (empty($bannerurl)){
;echo '<center><p>No \'bannerurl\' entered. Click <a href=approveads.php>here</a> to go back<p></center> ';
include '/footer.php';
exit;
}
$query = "update buttons set status='$approved', bannerurl='$bannerurl', url='$targeturl'  where id=".$id;
$result = mysql_query ($query) or die ('Query failed');
echo "<p align=\"center\"><span style=\"background-color: #FFFF00; color: #FF0000;font-size: 12px; width: 234px;\">125X125 Banner has been edited.</span></p>";
header('refresh: 1; url=approveads.php');
}
else {
$id = $_GET['id'];
$query2 = "select * from buttons where id='".$id."'  LIMIT 1";
$result2 = mysql_query ($query2) or die ('Query2 failed');
$line = mysql_fetch_array($result2);
$id = $line['id'];
$bannerurl = $line['bannerurl'];
$targeturl = $line['url'];
;echo '
<center><H2>Edit Button Banner</H2><br>
<form method="POST">
<img src="';echo $bannerurl;;echo '"><br><br>
Target Url:<br>
<input type="text" name="targeturl" size="50" value="';echo $targeturl;;echo '"><br><br>
Banner Url:<br>
<input type="text" name="bannerurl" size="50" value="';echo $bannerurl;;echo '"><br><br>
<input type="hidden" name="approved" maxsize="1" value=0><br><br>
<input type="hidden" name="id" value="';echo $id;;echo '">
<input type="hidden" name="done" value="YES">
<input type="submit" value="Save">
</form></center>

';
}
}
if($type==text) {
if ($done == 'YES') {
if (empty($url)){
;echo '<center><p>No \'url\' entered. Click <a href=approveads.php>here</a> to go back<p></center> ';
include '/footer.php';
exit;
}
if (empty($subject)){
;echo '<center><p>No \'subject\' entered. Click <a href=approveads.php>here</a> to go back<p></center> ';
include '/footer.php';
exit;
}
$query = "update texts set approved='$approved', subject='$subject', url='$url'  where id=".$id;
$result = mysql_query ($query) or die ('Query failed');
echo "<p align=\"center\"><span style=\"background-color: #FFFF00; color: #FF0000;font-size: 12px; width: 234px;\">Text Link has been edited.</span></p>";
header('refresh: 1; url=approveads.php');
}
else {
$id = $_GET['id'];
$query2 = "select * from texts where id='".$id."'  LIMIT 1";
$result2 = mysql_query ($query2)
or die ('Query2 failed');
$line = mysql_fetch_array($result2);
$id = $line['id'];
$subject = $line['subject'];
$url = $line['url'];
;echo '
<center><H2>Edit Text Link</H2><br>
<form method="POST">
Subject:<br>
<input type="text" name="subject" size="50" value="';echo $subject;;echo '"><br><br>
Url:<br>
<input type="text" name="url" size="50" value="';echo $url;;echo '"><br><br>
<input type="hidden" name="approved" maxsize="1" value=0><br><br>
<input type="hidden" name="id" value="';echo $id;;echo '">
<input type="hidden" name="done" value="YES">
<input type="submit" value="Save">
</form></center>

';
}
}
}
function queryprosignupads2 () {
$query = mysql_query("SELECT * FROM signup_ads WHERE memtype='PRO' LIMIT 1");
return $query;
}
function queryjvsignupads2 () {
$query = mysql_query("SELECT * FROM signup_ads WHERE memtype='JV Member' LIMIT 1");
return $query;
}
function querysuperjvsignupads2 () {
$query = mysql_query("SELECT * FROM signup_ads WHERE memtype='SUPER JV' LIMIT 1");
return $query;
}
function queryproads2 () {
$query = mysql_query("SELECT * FROM monthlyads WHERE memtype='PRO' LIMIT 1");
return $query;
}
function queryjvads2 () {
$query = mysql_query("SELECT * FROM monthlyads WHERE memtype='JV Member' LIMIT 1");
return $query;
}
function querysuperjvads2 () {
$query = mysql_query("SELECT * FROM monthlyads WHERE memtype='SUPER JV' LIMIT 1");
return $query;
}
function selectreward($each) {
if($each == banner) {
$type='468X60 Banner';
}if($each == button) {
$type='125X125 Banner';
}if($each == text) {
$type='Text Link';
}
return $type;
}
function selectnologin() {
$query = 'SELECT * FROM `members` WHERE `lastlogin` BETWEEN DATE_SUB( CURDATE( ) ,INTERVAL 2 YEAR ) AND DATE_SUB( CURDATE( ) ,INTERVAL 30 DAY ) and verified=1 and vacation=0 ORDER BY `members`.`lastlogin` ASC';
$result = mysql_query ($query) or die ('Query failed');
return $result;
}
function sendwarning($each) {
$queryr = "select * from members where userid='$each' LIMIT 1";
$resultr = mysql_query( $queryr )
or die( 'Connection error. Please check whether the MySQL service is running or not.');
$array = mysql_fetch_array( $resultr );
$id = $array['id'];
$uname = $array['userid'];
$fname = $array['name'];
$pword = $array['pword'];
$contactemail = $array['contact_email'];
$joindate = $array['joindate'];
$lastlogin = $array['lastlogin'];
$queryf = 'select * from inactivemembers where id=1';
$resultf = mysql_query( $queryf )
or die( 'Connection error. Please check whether the MySQL service is running or not.');
$array = mysql_fetch_array( $resultf );
$message = $array['warningemail'];
$subject = $array['subject'];
$message = str_replace('~uname~',$uname,$message);
$message = str_replace('~name~',$fname,$message);
$message = str_replace('~pass~',$pword,$message);
$message = str_replace('~ename~',$sitename,$message);
$message = str_replace('~domain~',$domain,$message);
$message = str_replace('~joindate~',$joindate,$message);
$message = str_replace('~lastlogin~',$lastlogin,$message);
$subject = str_replace('~uname~',$uname,$subject);
$subject = str_replace('~name~',$fname,$subject);
$subject = str_replace('~pass~',$pword,$subject);
$subject = str_replace('~ename~',$sitename,$subject);
sendoutmail ($contactemail,$fname,$subject,$message);
$counter=$counter+1;
$sqlquery = "insert into mailedmembers values ($id, 1, '".date('Y-m-d')."')";
$result = mysql_query( $sqlquery ) or die( 'Connection error. Please check whether the MySQL service is running or not.');
}
function transtype($type) {
if($type==1) {
$table="`action` NOT LIKE \"%Prize:%\" AND `action` NOT LIKE\"%Referral:%\" AND `action` NOT LIKE\"%Monthly:%\" AND `action` NOT LIKE\"%Signup:%\"";
}
if($type==2) {
$table="`action` LIKE \"%Referral:%\"";
}
if($type==3) {
$table="`action` LIKE \"%Prize:%\"";
}
if($type==4) {
$table="`action` LIKE \"%Monthly:%\"";
}
if($type==5) {
$table="`action` LIKE \"%Signup:%\"";
}
return $table;
}
function sitecheck() {
;echo '<html>
<center>
<body bgcolor="#FFFF00">
Please wait <span id="plzwait">3 seconds</span>
<script type="text/javascript">
counter = 3;
function countdown() {
if ((0 <= 100) || (0 > 0)) {
counter--;
if(counter > 0) {
document.getElementById("plzwait").innerHTML = \'<b>\'+counter+\'<\/b> seconds\';
setTimeout(\'countdown()\',1000);
}
}
}
countdown();
</script>
</body>
</html>
';
}
function checkuser ($userid) {
$check = mysql_query("SELECT userid FROM members WHERE userid='$userid' LIMIT 1");
$check_num_rows = mysql_num_rows($check);
if ($check_num_rows==0) {
$str="The userid you entered is not a valid user<br><a href=\"\">Go Back</a>";
return $str;
}
}
function addads ($userid,$max,$type,$quantity) {
$check=checkuser ($userid);
if($check) {
print $check;
include '/footer.php';
exit;
}
if($type=='CHOOSE AD TYPE') {
echo "Please Choose Ad Type <a href=\"\">Go Back</a>";
include '/footer.php';
exit;
}elseif($type=='468x60 Banner Ad') {
$query = "insert into banners (userid,max) values('$userid','$max')";
}elseif($type=='125x125 Banner Ad') {
$query = "insert into buttons (userid,max) values('$userid','$max')";
}elseif($type=='Text Link Ad') {
$query = "insert into texts (userid,paid,ptc) values('$userid','$max','0')";
}
$count = 0;
$quantity = $quantity;
while($quantity >$count) {
$count++;
mysql_query ($query);
}
print '<p><center>'.$quantity." blank $type ad has been added to ".$userid."'s account.</p></center>";
mysql_query("INSERT INTO ad_ledger VALUES ('id','".$userid."','admin manually added $type','".time()."','$quantity')");
mysql_query("INSERT INTO account_ledger VALUES ('id','".$userid."','admin manually added $type to your account','".time()."','$quantity')");
}
function viewbanners () {
global $fonttype,$fontcolour,$basecolour;
if($_POST['submit'] == 'Delete') {
$id = $_POST['id'];
$query1 = "delete from banners where id='".$id."'";
$result1 = mysql_query ($query1);
echo 'The ad has been deleted!';
;echo '<head>
<META HTTP-EQUIV="Refresh"
CONTENT="0; URL=viewads.php?action=View&type=468X60+Banners">
</head>
';
}
if($_POST['submit'] == 'Suspend') {
$id = $_POST['id'];
$query = 'update banners set status=0 where id='.$id;
$result = mysql_query ($query)
or die ('Query failed');
echo '<p><center>The banner ad has been sent back to the user.</p></center>';
;echo '<head>
<META HTTP-EQUIV="Refresh"
CONTENT="0; URL=viewads.php?action=View&type=468X60+Banners">
</head>
';
}
if($_POST['action'] == 'completed') {
$sql = mysql_query("SELECT id FROM banners WHERE status=1 AND date<='".(time()-31*24*60*60)."'");
while($each = mysql_fetch_array($sql)) {
mysql_query("DELETE FROM banners where id='".$each['id']."'");
}
echo 'All the completed banner campaigns have been deleted!';
;echo '
<head>

<META HTTP-EQUIV="Refresh"

CONTENT="0; URL=viewads.php?action=View&type=468X60+Banners">

</head>
';
}
$adjacents = 3;
echo '<center><H2>468X60 Banner Ads</H2></center>';
if($_REQUEST['active']==1) {
$query = 'SELECT COUNT(*) as num FROM banners WHERE status=1 and shown<max';
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$targetpage = 'viewads.php?action=View&type=468X60+Banners&active=1';
$limit = 25;
$page = $_GET['page'];
if($page) 
$start = ($page -1) * $limit;
else
$start = 0;
$sql = "SELECT * FROM banners WHERE status=1 and shown<max LIMIT $start, $limit";
}elseif($_REQUEST['active']) {
$query = 'SELECT COUNT(*) as num FROM banners';
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$targetpage = 'viewads.php?action=View&type=468X60+Banners';
$limit = 25;
$page = $_GET['page'];
if($page) 
$start = ($page -1) * $limit;
else
$start = 0;
$sql = "SELECT * FROM banners ORDER BY status DESC LIMIT $start, $limit";
}
else {
$query = 'SELECT COUNT(*) as num FROM banners';
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$targetpage = 'viewads.php?action=View&type=468X60+Banners';
$limit = 25;
$page = $_GET['page'];
if($page) 
$start = ($page -1) * $limit;
else
$start = 0;
$sql = "SELECT * FROM banners ORDER BY status DESC LIMIT $start, $limit";
}
$result = mysql_query ($sql) or die ('Query failed');
$result2 = mysql_query ($query) or die ('Query failed');
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
if($_REQUEST['active']) {
echo "<b><a href=\"viewads.php?action=View&type=468X60+Banners&active=0\">Click here to view all 468X60 banners</a></b>";
}else
echo "<b><a href=\"viewads.php?action=View&type=468X60+Banners&active=1\">Click here to view only active 468X60 banners</a></b>";
echo "<font size=2 face='$fonttype' color='$fontcolour'><p><center>";
echo '<center><p><b>';
echo "$total_pages 468x60 banner ads found";
echo '</center></p></b>';
if ($page == 0) $page = 1;
$prev = $page -1;
$next = $page +1;
$lastpage = ceil($total_pages/$limit);
$lpm1 = $lastpage -1;
$pagination = '';
if($lastpage >1)
{
$pagination .= "<div class=\"pagination\">";
if ($page >1) 
$pagination.= "<a href=\"$targetpage&page=$prev\">« previous</a>";
else
$pagination.= "<span class=\"disabled\">« previous</span>";
if ($lastpage <7 +($adjacents * 2))	
{
for ($counter = 1;$counter <= $lastpage;$counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
}
elseif($lastpage >5 +($adjacents * 2))	
{
if($page <1 +($adjacents * 2))		
{
for ($counter = 1;$counter <4 +($adjacents * 2);$counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
$pagination.= '...';
$pagination.= "<a href=\"$targetpage&page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage&page=$lastpage\">$lastpage</a>";
}
elseif($lastpage -($adjacents * 2) >$page &&$page >($adjacents * 2))
{
$pagination.= "<a href=\"$targetpage&page=1\">1</a>";
$pagination.= "<a href=\"$targetpage&page=2\">2</a>";
$pagination.= '...';
for ($counter = $page -$adjacents;$counter <= $page +$adjacents;$counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
$pagination.= '...';
$pagination.= "<a href=\"$targetpage&page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage&page=$lastpage\">$lastpage</a>";
}
else
{
$pagination.= "<a href=\"$targetpage&page=1\">1</a>";
$pagination.= "<a href=\"$targetpage&page=2\">2</a>";
$pagination.= '...';
for ($counter = $lastpage -(2 +($adjacents * 2));$counter <= $lastpage;$counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
}
}
if ($page <$counter -1) 
$pagination.= "<a href=\"$targetpage&page=$next\">next »</a>";
else
$pagination.= "<span class=\"disabled\">next »</span>";
$pagination.= "</div>
";
}
;echo '<table>
<tr>

<td valign="top" align="center"><br><br> ';
;echo '<table align=center><tr><td>';echo $pagination;echo '</td></tr></table>
<table width=70% border=0 cellpadding=2 cellspacing=2>	        ';
while ($line = mysql_fetch_array($result)) {
$id = $line['id'];
$userid = $line['userid'];
$added = $line['added'];
$name = $line['name'];
$max = $line['max'];
$shown = $line['shown'];
$approved = $line['status'];
$targeturl = $line['url'];
$bannerurl = $line['bannerurl'];
$clicks = $line['clicks'];
if ($added=='1') {
$added='Yes';
}
else {
$added='No';
}
if ($approved=='1') {
$approved='Yes';
}
else {
$approved='No';
}
;echo '<tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Userid:&nbsp;';echo $userid;;echo '</font></center></td></tr> <tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Approved:&nbsp;';echo $approved;;echo '</font></center></td></tr><tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Added:&nbsp;';echo $added;;echo '</font></center></td></tr><tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Max:&nbsp;';echo $max;;echo '</font></center></td></tr><tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Shown:&nbsp;';echo $shown;;echo '</font></center></td></tr><tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Clicks:&nbsp;';echo $clicks;;echo '</font></center></td></tr><tr>
<td bgcolor="';echo $basecolour;;echo '">

<font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';if($added=='Yes') {;echo '<img src="';echo $bannerurl;;echo '" width="234 height="30" border="0">';};echo '<br>Banner Url: ';echo $bannerurl;;echo '<br>Banner Link: <a href="sitecheck.php?url=';echo $targeturl;;echo '" target="_blank">';echo $targeturl;;echo '</a></font></center><br></td></tr> <tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">
<form method="POST" action="viewads.php?action=View&type=468X60+Banners">
<input type="hidden" name="id" value="';echo $id;;echo '">
<input type="submit" name="submit" value="Delete">
</form>
</center>
</td></tr><tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">
<form method="POST" action="viewads.php?action=View&type=468X60+Banners">
<input type="hidden" name="id" value="';echo $id;;echo '">
<input type="submit" name="submit" value="Suspend">
</form>
</center>
</td></tr>

</td></tr> 

<tr>
<td>&nbsp;</td>

</tr>


';
}
echo '</table></center>';
;echo '<table align=center><tr><td>';echo $pagination;echo '</td></tr></table>
';
echo '</td></tr></table>';
}
function viewcreditmail () {
;echo '		<h2>Credits Mailer Stats</h2>
';
$sql = mysql_query('SELECT * FROM membermail ORDER BY timestamp DESC');
if(@mysql_num_rows($sql)) {
echo "<table border=1 cellpadding=5 width=\"70%\"><tr><th>Subject</th><th>Date</th><th>Sent to</th><th>Clicks</th></tr>";
while($each = mysql_fetch_array($sql)) {
echo "<tr><td><a href=\"".$each['url']."\" target=\"_blank\">".$each['subject'].'</a></td><td align=center>'.date('Y-m-d',$each['timestamp']).'</td><td align=center>'.$each['sentto'].'</td><td align=center>'.$each['clicks'].'</td></tr>';
}
echo '</table>';
}else {
echo 'No credit mails have been sent.';
}
}
function viewbuttons () {
global $fonttype,$fontcolour,$basecolour;
if($_POST['submit'] == 'Delete') {
$id = $_POST['id'];
$query1 = "delete from buttons where id='".$id."'";
$result1 = mysql_query ($query1);
echo 'The ad has been deleted!';
;echo '<head>
<META HTTP-EQUIV="Refresh"
CONTENT="0; URL=viewads.php?action=View&type=125X125+Banners">
</head>
';
}
if($_POST['submit'] == 'Suspend') {
$id = $_POST['id'];
$query = 'update buttons set status=0 where id='.$id;
$result = mysql_query ($query)
or die ('Query failed');
echo '<p><center>The banner ad has been sent back to the user.</p></center>';
;echo '<head>
<META HTTP-EQUIV="Refresh"
CONTENT="0; URL=viewads.php?action=View&type=125X125+Banners">
</head>
';
}
if($_POST['action'] == 'completed') {
$sql = mysql_query("SELECT id FROM buttons WHERE status=1 AND date<='".(time()-31*24*60*60)."'");
while($each = mysql_fetch_array($sql)) {
mysql_query("DELETE FROM buttons where id='".$each['id']."'");
}
echo 'All the completed banner campaigns have been deleted!';
;echo '
<head>

<META HTTP-EQUIV="Refresh"

CONTENT="0; URL=viewads.php?action=View&type=125X125+Banners">

</head>
';
}
$adjacents = 3;
echo '<center><H2>125X125 Banner Ads</H2></center>';
if($_REQUEST['active']==1) {
$query = 'SELECT COUNT(*) as num FROM buttons WHERE status=1 and shown<max';
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$targetpage = 'viewads.php?action=View&type=125X125+Banners&active=1';
$limit = 25;
$page = $_GET['page'];
if($page) 
$start = ($page -1) * $limit;
else
$start = 0;
$sql = "SELECT * FROM buttons WHERE status=1 and shown<max LIMIT $start, $limit";
}elseif($_REQUEST['active']) {
$query = 'SELECT COUNT(*) as num FROM buttons';
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$targetpage = 'viewads.php?action=View&type=125X125+Banners';
$limit = 25;
$page = $_GET['page'];
if($page) 
$start = ($page -1) * $limit;
else
$start = 0;
$sql = "SELECT * FROM buttons ORDER BY status DESC LIMIT $start, $limit";
}
else {
$query = 'SELECT COUNT(*) as num FROM buttons';
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$targetpage = 'viewads.php?action=View&type=125X125+Banners';
$limit = 25;
$page = $_GET['page'];
if($page) 
$start = ($page -1) * $limit;
else
$start = 0;
$sql = "SELECT * FROM buttons ORDER BY status DESC LIMIT $start, $limit";
}
$result = mysql_query ($sql) or die ('Query failed');
$result2 = mysql_query ($query) or die ('Query failed');
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
if($_REQUEST['active']) {
echo "<b><a href=\"viewads.php?action=View&type=125X125+Banners&active=0\">Click here to view all 125X125 buttons</a></b>";
}else
echo "<b><a href=\"viewads.php?action=View&type=125X125+Banners&active=1\">Click here to view only active 125X125 buttons</a></b>";
echo "<font size=2 face='$fonttype' color='$fontcolour'><p><center>";
echo '<center><p><b>';
echo "$total_pages 125X125 banner ads found";
echo '</center></p></b>';
if ($page == 0) $page = 1;
$prev = $page -1;
$next = $page +1;
$lastpage = ceil($total_pages/$limit);
$lpm1 = $lastpage -1;
$pagination = '';
if($lastpage >1)
{
$pagination .= "<div class=\"pagination\">";
if ($page >1) 
$pagination.= "<a href=\"$targetpage&page=$prev\">« previous</a>";
else
$pagination.= "<span class=\"disabled\">« previous</span>";
if ($lastpage <7 +($adjacents * 2))	
{
for ($counter = 1;$counter <= $lastpage;$counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
}
elseif($lastpage >5 +($adjacents * 2))	
{
if($page <1 +($adjacents * 2))		
{
for ($counter = 1;$counter <4 +($adjacents * 2);$counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
$pagination.= '...';
$pagination.= "<a href=\"$targetpage&page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage&page=$lastpage\">$lastpage</a>";
}
elseif($lastpage -($adjacents * 2) >$page &&$page >($adjacents * 2))
{
$pagination.= "<a href=\"$targetpage&page=1\">1</a>";
$pagination.= "<a href=\"$targetpage&page=2\">2</a>";
$pagination.= '...';
for ($counter = $page -$adjacents;$counter <= $page +$adjacents;$counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
$pagination.= '...';
$pagination.= "<a href=\"$targetpage&page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage&page=$lastpage\">$lastpage</a>";
}
else
{
$pagination.= "<a href=\"$targetpage&page=1\">1</a>";
$pagination.= "<a href=\"$targetpage&page=2\">2</a>";
$pagination.= '...';
for ($counter = $lastpage -(2 +($adjacents * 2));$counter <= $lastpage;$counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
}
}
if ($page <$counter -1) 
$pagination.= "<a href=\"$targetpage&page=$next\">next »</a>";
else
$pagination.= "<span class=\"disabled\">next »</span>";
$pagination.= "</div>
";
}
;echo '<table>
<tr>

<td valign="top" align="center"><br><br> ';
;echo '<table align=center><tr><td>';echo $pagination;echo '</td></tr></table>
<table width=70% border=0 cellpadding=2 cellspacing=2>	        ';
while ($line = mysql_fetch_array($result)) {
$id = $line['id'];
$userid = $line['userid'];
$added = $line['added'];
$name = $line['name'];
$max = $line['max'];
$shown = $line['shown'];
$approved = $line['status'];
$targeturl = $line['url'];
$bannerurl = $line['bannerurl'];
$clicks = $line['clicks'];
if ($added=='1') {
$added='Yes';
}
else {
$added='No';
}
if ($approved=='1') {
$approved='Yes';
}
else {
$approved='No';
}
;echo '<tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Userid:&nbsp;';echo $userid;;echo '</font></center></td></tr> <tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Approved:&nbsp;';echo $approved;;echo '</font></center></td></tr><tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Added:&nbsp;';echo $added;;echo '</font></center></td></tr><tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Max:&nbsp;';echo $max;;echo '</font></center></td></tr><tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Shown:&nbsp;';echo $shown;;echo '</font></center></td></tr><tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Clicks:&nbsp;';echo $clicks;;echo '</font></center></td></tr><tr>
<td bgcolor="';echo $basecolour;;echo '">

<font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';if($added=='Yes') {;echo '<img src="';echo $bannerurl;;echo '" width="62" height="62" border="0">';};echo '<br>Banner Url: ';echo $bannerurl;;echo '<br>Banner Link: <a href="sitecheck.php?url=';echo $targeturl;;echo '" target="_blank">';echo $targeturl;;echo '</a></font></center><br></td></tr> <tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">
<form method="POST" action="viewads.php?action=View&type=125X125+Banners">
<input type="hidden" name="id" value="';echo $id;;echo '">
<input type="submit" name="submit" value="Delete">
</form>
</center>
</td></tr><tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">
<form method="POST" action="viewads.php?action=View&type=125X125+Banners">
<input type="hidden" name="id" value="';echo $id;;echo '">
<input type="submit" name="submit" value="Suspend">
</form>
</center>
</td></tr>

</td></tr> 

<tr>
<td>&nbsp;</td>

</tr>


';
}
echo '</table></center>';
;echo '<table align=center><tr><td>';echo $pagination;echo '</td></tr></table>
';
echo '</td></tr></table>';
}
function viewtexts () {
global $fonttype,$fontcolour,$basecolour;
if($_REQUEST['active']==1)
$act=1;
if($_POST['submit'] == 'Delete Permanent') {
$id = $_POST['id'];
foreach($id as $each) {
$query1 = "delete from texts where id='".$each."'";
$result1 = mysql_query ($query1);
}
echo 'The ad has been deleted!';
;echo '<head>
<META HTTP-EQUIV="Refresh"
CONTENT="10; URL=viewads.php?action=View&type=Text+Links&active=".$act."">
</head>
';
}
if($_POST['submit'] == 'Send Back') {
$id = $_POST['id'];
foreach($id as $each) {
$query = 'update texts set approved=0 where id='.$each;
$result = mysql_query ($query)
or die ('Query failed');
}
echo '<p><center>The text ad has been sent back to the user.</p></center>';
;echo '<head>
<META HTTP-EQUIV="Refresh"
CONTENT="10; URL=viewads.php?action=View&type=Text+Links&active=".$act."">
</head>
';
}
if($_POST['action'] == 'completed') {
$sql = mysql_query("SELECT id FROM texts WHERE approved=1 AND date<='".(time()-31*24*60*60)."'");
while($each = mysql_fetch_array($sql)) {
mysql_query("DELETE FROM texts where id='".$each['id']."'");
}
echo 'All the completed text link campaigns have been deleted!';
;echo '
<head>

<META HTTP-EQUIV="Refresh"

CONTENT="10; URL=viewads.php?action=View&type=Text+Links&active=".$act."">

</head>
';
}
$adjacents = 3;
echo '<center><H2>Text Links Ads</H2></center>';
if($_REQUEST['active']==1) {
$query = 'SELECT COUNT(*) as num FROM texts WHERE approved=1 and paid>sent';
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$targetpage = 'viewads.php?action=View&type=Text+Links&active=1';
$limit = 25;
$page = $_GET['page'];
if($page) 
$start = ($page -1) * $limit;
else
$start = 0;
$sql = "SELECT * FROM texts WHERE approved=1 and paid>sent LIMIT $start, $limit";
}elseif($_REQUEST['active']) {
$query = 'SELECT COUNT(*) as num FROM texts';
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$targetpage = 'viewads.php?action=View&type=Text+Links';
$limit = 25;
$page = $_GET['page'];
if($page) 
$start = ($page -1) * $limit;
else
$start = 0;
$sql = "SELECT * FROM texts ORDER BY approved DESC LIMIT $start, $limit";
}
else {
$query = 'SELECT COUNT(*) as num FROM texts';
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
$targetpage = 'viewads.php?action=View&type=Text+Links';
$limit = 25;
$page = $_GET['page'];
if($page) 
$start = ($page -1) * $limit;
else
$start = 0;
$sql = "SELECT * FROM texts ORDER BY approved DESC LIMIT $start, $limit";
}
$result = mysql_query ($sql) or die ('Query failed');
$result2 = mysql_query ($query) or die ('Query failed');
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
if($_REQUEST['active']) {
echo "<b><a href=\"viewads.php?action=View&type=Text+Links&active=0\">Click here to view all text links</a></b>";
}else
echo "<b><a href=\"viewads.php?action=View&type=Text+Links&active=1\">Click here to view only active text links</a></b>";
echo "<font size=2 face='$fonttype' color='$fontcolour'><p><center>";
echo '<center><p><b>';
echo "$total_pages text link ads found";
echo '</center></p></b>';
if ($page == 0) $page = 1;
$prev = $page -1;
$next = $page +1;
$lastpage = ceil($total_pages/$limit);
$lpm1 = $lastpage -1;
$pagination = '';
if($lastpage >1)
{
$pagination .= "<div class=\"pagination\">";
if ($page >1) 
$pagination.= "<a href=\"$targetpage&page=$prev\">« previous</a>";
else
$pagination.= "<span class=\"disabled\">« previous</span>";
if ($lastpage <7 +($adjacents * 2))	
{
for ($counter = 1;$counter <= $lastpage;$counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
}
elseif($lastpage >5 +($adjacents * 2))	
{
if($page <1 +($adjacents * 2))		
{
for ($counter = 1;$counter <4 +($adjacents * 2);$counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
$pagination.= '...';
$pagination.= "<a href=\"$targetpage&page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage&page=$lastpage\">$lastpage</a>";
}
elseif($lastpage -($adjacents * 2) >$page &&$page >($adjacents * 2))
{
$pagination.= "<a href=\"$targetpage&page=1\">1</a>";
$pagination.= "<a href=\"$targetpage&page=2\">2</a>";
$pagination.= '...';
for ($counter = $page -$adjacents;$counter <= $page +$adjacents;$counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
$pagination.= '...';
$pagination.= "<a href=\"$targetpage&page=$lpm1\">$lpm1</a>";
$pagination.= "<a href=\"$targetpage&page=$lastpage\">$lastpage</a>";
}
else
{
$pagination.= "<a href=\"$targetpage&page=1\">1</a>";
$pagination.= "<a href=\"$targetpage&page=2\">2</a>";
$pagination.= '...';
for ($counter = $lastpage -(2 +($adjacents * 2));$counter <= $lastpage;$counter++)
{
if ($counter == $page)
$pagination.= "<span class=\"current\">$counter</span>";
else
$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";
}
}
}
if ($page <$counter -1) 
$pagination.= "<a href=\"$targetpage&page=$next\">next »</a>";
else
$pagination.= "<span class=\"disabled\">next »</span>";
$pagination.= "</div>
";
}
;echo '<table align=center><tr><td>';echo $pagination;echo '</td></tr></table>
<form method=POST action="viewads.php?action=View&type=Text+Links&active=';echo $act;;echo '" name=ads>   	 
<table align="center" bgcolor="#000000" style="width: 625px; margin-left: auto; margin-right: auto; border: 1px solid rgb(0, 0, 0);" align="center" cellpadding="1" cellspacing="1">
<tr>
<td bgcolor="#CCCCCC">&nbsp;</td>
<td bgcolor="#CCCCCC"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>Userid</font></center></td>
<td bgcolor="#CCCCCC"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>Subject</font></center></td>
<td bgcolor="#CCCCCC"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>Paid</font></center></td>
<td bgcolor="#CCCCCC"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>Sent</font></center></td>
</tr>      

';
$i=0;
while ($line = mysql_fetch_array($result)) {
$id = $line['id'];
$userid = $line['userid'];
$added = $line['added'];
$subject = $line['subject'];
$paid = $line['paid'];
$sent = $line['sent'];
$approved = $line['approved'];
$url = $line['url'];
$bg=tbcolor($i);
$i=$i+1;
if ($added=='1') {
$added='Yes';
}
else {
$added='No';
}
if ($approved=='1') {
$approved='Yes';
}
else {
$approved='No';
}
;echo '<tr>
<td bgcolor="';echo $bg;;echo '"><input type="checkbox" name="id[]" value="';echo $id;;echo '"></td>
<td bgcolor="';echo $bg;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center><a href="memberlogin.php?userid=';echo $userid;;echo '">';echo $userid;;echo '</a></center></td>
<td bgcolor="';echo $bg;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center><a href="sitecheck.php?url=';echo $url;;echo '" target="_blank">';echo $subject;;echo '</a></font></center></td>
<td bgcolor="';echo $bg;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $paid;;echo '</font></center></td>
<td bgcolor="';echo $bg;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $sent;;echo '</font></center></td>

</tr>


';
}
echo '</table><input type="button" onClick="return Inverse(document.ads);" value="Inverse"><input type="submit" name="submit" value="Delete Permanent"><input type="submit" name="submit" value="Send Back"></center>';
;echo '<table align=center><tr><td>';echo $pagination;echo '</td></tr></table>
';
echo '</td></tr></table>';
}
function navigation () {
global $fonttype,$fontcolour,$basecolour,$contrastcolour,$status;
$index=$_REQUEST['index'];
$name=$_REQUEST['name'];
$url=$_REQUEST['url'];
$status=$_REQUEST['status'];
$seq=$_REQUEST['seq'];
$memtype=$_REQUEST['memtype'];
$target=$_REQUEST['target'];
$owner=$_REQUEST['owner'];
$action = $_POST['action'];
if($_POST['action'] == 'change') {
$index = $_POST['index'];
$setting = $_POST['status'];
$query = "update navigation set status='".$status."' where id=".$index;
$result = mysql_query ($query) or die ('Query failed');
echo '<br><br><center><b>Status changed.</b></center>';
}
if($_POST['action'] == 'add') {
$name = $_POST['name'];
$url = $_POST['url'];
$seq = $_POST['seq'];
$memtype = $_POST['memtype'];
$target = $_POST['target'];
$owner = $_POST['owner'];
$query = "insert into navigation (name,url,status,seq,memtype,target,owner) VALUES ('$name','$url','ON','$seq','$memtype','$target','$owner')";
$result = mysql_query ($query) or die ('Insert failed');
echo '<br><br><center><b>Your new navigation has been saved.</b></center>';
}
if($_POST['action'] == 'AddNav') {
;echo ' <center>
<p>Add a navigation button to the members area.</p>
<form method="POST">
Name:<br><input type="text" name="name" value=""><br>
Url:<br><input type="text" name="url" value=""><br>
Sequence:<br><input type="text" name="seq" value=""><br>
Parent:<br><input type="text" name="owner" value=""><br>
Membership type:<br>
<select name="memtype">
<option>All</option>
<option>PRO</option>
<option>JV Member</option>
<option>SUPER JV</option>

</select><br><br>
Target Window: <select name="target">
<option value="_top" ';if ($target == '_top') {echo 'selected';};echo '>Open in Current Window</option>
<option value="_blank" ';if ($target != '_top') {echo 'selected';};echo '>Open in New Window</option>
</select>

<input type="hidden" name="action" value="add"><br>
<input type="submit" value="Add">
</form>
</center>
';
}
if($_POST['action'] == 'edit') {
$index = $_POST['index'];
$name = $_POST['name'];
$url = $_POST['url'];
$seq = $_POST['seq'];
$memtype = $_POST['memtype'];
$target = $_POST['target'];
$owner = $_POST['owner'];
$query = "update navigation set name='".$name."', url='".$url."', seq=".$seq.", memtype='$memtype', target='$target', owner='$owner' where id=".$index;
$result = mysql_query ($query) or die ('Edit failed');
echo 'Your changes have been saved.';
}
if($_POST['action'] == 'EditNav') {
;echo '<center>
<p>Edit members area navigation (';echo $name;;echo '):</p>
<form method="POST">
<input type="hidden" name="index" value=';echo $index;;echo '>
Name:<input type="text" name="name" value="';echo $name;;echo '"><br>
Url:<input type="text" name="url" value=';echo $url;;echo '><br>
Sequence:<input type="text" name="seq" value=';echo $seq;;echo '><br>
Parent:<input type="text" name="owner" value=';echo $owner;;echo '><br>
Membership type:<br>
<input type="radio" name="memtype" value="All"';if($memtype=='All') echo ' CHECKED';;echo '> All
<input type="radio" name="memtype" value="PRO"';if($memtype=='PRO') echo ' CHECKED';;echo '> PRO
<input type="radio" name="memtype" value="JV Member"';if($memtype=='JV Member') echo ' CHECKED';;echo '> JV Member
<input type="radio" name="memtype" value="SUPER JV"';if($memtype=='SUPER JV') echo ' CHECKED';;echo '> SUPER JV
<input type="hidden" name="action" value="edit"><br>
Target Window: <select name="target">
<option value="_top" ';if ($target == '_top') {echo 'selected';};echo '>Open in Current Window</option>
<option value="_blank" ';if ($target != '_top') {echo 'selected';};echo '>Open in New Window</option>
</select>

<input type="submit" value="Save">
</form>
</center>
';
}
if($_POST['action'] == 'Delete') {
$index = $_POST['index'];
$query1 = "delete from navigation where id='".$index."'";
$result1 = mysql_query ($query1);
echo 'The navigation link has been deleted!';
}
if($_POST['action'] == 'DeleteCheck') {
;echo '<p>Delete Link: ';echo $name;;echo ':</p>

<form method=POST>
<input type="hidden" name="index" value="';echo $index;;echo '">
<input type="hidden" name="action" value="Delete">
<input type="submit" value="Yes I Confirm ';echo $name;;echo ' Link Deletion">
</form>

';
}
$query = 'SELECT distinct * FROM navigation order by seq';
$result = mysql_query ($query)
or die ('Query failed');
;echo ' <center>
<p>These are the navigations that are shown in the members area.<br>You can add new navigations here or set these to inactive.</p>
<form method=POST>
<input type="hidden" name="action" value="AddNav">
<input type="submit" value="Add Nav Link">
</form>   

<br><br>
';
echo '<table width=90% border=0 cellpadding=2 cellspacing=2>';
;echo '  		<tr>
<td bgcolor="';echo $contrastcolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Id</font></td>
<td bgcolor="';echo $contrastcolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Name</font></td>
<td bgcolor="';echo $contrastcolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Url</font></td>
<td bgcolor="';echo $contrastcolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Status</font></td>
<td bgcolor="';echo $contrastcolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Order</font></td>
<td bgcolor="';echo $contrastcolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Parent</font></td>
<td bgcolor="';echo $contrastcolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Target</font></td>
<td bgcolor="';echo $contrastcolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Members</font></td>
<td bgcolor="';echo $contrastcolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Edit</font></td>

</tr>
';
while ($line = mysql_fetch_array($result)) {
$parentid = $line['id'];
$name = $line['name'];
$url = $line['url'];
$status = $line['status'];
$index = $line['id'];
$seq = $line['seq'];
$memtype = $line['memtype'];
$target = $line['target'];
$owner = $line['owner'];
;echo '  		<tr>
<td bgcolor="';echo $basecolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">';echo $parentid;;echo '</font></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">';echo $name;;echo '</font></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">';echo $url;;echo '</font></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">';echo $status;;echo '</font></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">';echo $seq;;echo '</font></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">';echo $owner;;echo '</font></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">';echo $target;;echo '</font></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">';echo ucfirst($memtype);;echo '</font></td>
<td bgcolor="';echo $basecolour;;echo '" valign="middle" align="center"><br>
<form method=POST>
<input type="hidden" name="index" value="';echo $index;;echo '">
<input type="hidden" name="action" value="EditNav">
<input type="hidden" name="name" value="';echo $name;;echo '">
<input type="hidden" name="url" value="';echo $url;;echo '">
<input type="hidden" name="seq" value="';echo $seq;;echo '">
<input type="hidden" name="owner" value="';echo $owner;;echo '">
<input type="hidden" name="target" value="';echo $target;;echo '">
<input type="hidden" name="memtype" value="';echo $memtype;;echo '">
<input type="submit" value="Edit">
</form>
<form method=POST>
<input type="hidden" name="index" value="';echo $index;;echo '">
<input type="hidden" name="action" value="DeleteCheck">
<input type="hidden" name="name" value="';echo $name;;echo '">
<input type="hidden" name="url" value="';echo $url;;echo '">
<input type="hidden" name="seq" value="';echo $seq;;echo '">
<input type="hidden" name="owner" value="';echo $owner;;echo '">
<input type="hidden" name="target" value="';echo $target;;echo '">
<input type="hidden" name="memtype" value="';echo $memtype;;echo '">
<input type="submit" value="Delete">
</form>


';if ($status == 'ON') {;echo '          		<form method=POST>
<input type="hidden" name="action" value="change">
<input type="hidden" name="index" value="';echo $index;;echo '">
<input type="hidden" name="status" value="OFF">
<input type="submit" value="Set Off">
</form>
';}if ($status == 'OFF') {;echo '          		<form method=POST>
<input type="hidden" name="action" value="change">
<input type="hidden" name="index" value="';echo $index;;echo '">
<input type="hidden" name="status" value="ON">
<input type="submit" value="Set On">
</form></td>

';};echo '         </tr>
';
}
;echo '
</table>
</td>
</tr>
</table>
';
}
function ototype($oto) {
if($oto['id']=='1') echo 'OTO 1';
elseif($oto['id']=='2') echo 'OTO 2';
else echo 'OTO 3';
}
function offertype($oto) {
if($oto['id']=='1') echo 'OFFER 1';
elseif($oto['id']=='2') echo 'OFFER 2';
elseif($oto['id']=='3') echo 'OFFER 3';
}
function oto($id) {
$sql = mysql_query('SELECT * FROM oto');
return $sql;
}
function offer($id) {
$sql = mysql_query('SELECT * FROM offer');
return $sql;
}
function otoid($id) {
$sql = mysql_query("SELECT * FROM oto WHERE id='".$id."' LIMIT 1");
return $sql;
}
function offerid($id) {
$sql = mysql_query("SELECT * FROM offer WHERE id='".$id."' LIMIT 1");
return $sql;
}
function upgrademember () {
global $fonttype,$fontcolour,$basecolour;
$userid = $_REQUEST['userid'];
$memtype = $_POST['memtype'];
$paycom = $_POST['paycom'];
if ($_POST['action']=='upgrade') {
if ($memtype == 'JV Member') {
upgrade('1',$paycom,$userid);
echo $userid." has been upgraded successfully to $memtype.";
}elseif ($memtype == 'SUPER JV') {
upgrade('2',$paycom,$userid);
echo $userid." has been upgraded successfully to $memtype.";
}else {
$query3 = "update members set memtype='$memtype' where userid='".$userid."'";
$result3 = mysql_query ($query3);
echo $userid.' has been downgraded successfully.';
mysql_query("INSERT INTO transactions VALUES ('id', '".$userid."','Membership downgrade','".time()."','')");
mysql_query("INSERT INTO ad_ledger VALUES ('id','".$userid."','admin manual membership downgrade','".time()."','')");
mysql_query("INSERT INTO account_ledger VALUES ('id','".$userid."','admin manual membership downgrade','".time()."','')");
}echo '</td></tr></table>';
}else {
echo "<font size=2 face='$fonttype' color='$fontcolour'><p><b><center>";;echo '	        <center>
<p>Upgrade (or downgrade) a member<br></p>
<form method="POST">
<input type="hidden" name="action" value="upgrade">
Userid:<input type="text" name="useridp" maxLength="50" size="40" value="';echo $userid;;echo '"><br>
Pay Commissions: <input type="radio" name="paycom" value="1"> Yes <input type="radio" name="paycom" value="0"';echo ' CHECKED';;echo '> No<br>

<br>
<select name="memtype">
<option>PRO</option>
<option>JV Member</option> 
<option>SUPER JV</option> 
</select>
<br>
<input type="submit" value="Save">
</form>




</center>
</td>
</tr>
</table>
';
}
}
function editpage () {
preview();
if($_POST['action'] == 'edit') {
$index = $_POST['index'];
$htmlcode = stripslashes($_POST['htmlcode']);
$str=updatepages($index,$htmlcode);
print $str;
}
$query = 'select * from pages ORDER BY id ASC';
$result = mysql_query ($query) or die ('Insert failed');
while ($line = mysql_fetch_array($result)) {
$index = $line['id'];
$name = $line['name'];
$htmlcode = $line['htmlcode'];
echo '<b>'.$name .'</b>';
;echo '<table align="center" bgcolor="#CCCCCC" style="border: 1px solid rgb(0, 0, 0);" align="center" cellpadding="0" cellspacing="0">
<tr><td>
<center>
<form method="POST">
<input type="hidden" name="index" value="';echo $index;;echo '">
<textarea rows=30 cols=75 name="htmlcode">';echo stripslashes($htmlcode);;echo '</textarea><br>
<INPUT TYPE="button" value="Preview " onClick="previewad(htmlcode.value)">
<input type="hidden" name="action" value="edit">		
<input type="submit" value="Save Changes">
</form>
</center>
</td></tr></table><br><br>====================<br><br><br>
';
}
}
function updatepages($index,$htmlcode) {
$index = $_POST['index'];
$htmlcode = $_POST['htmlcode'];
$query = "update pages set htmlcode='".$htmlcode."' where id='".$index."'";
$result = mysql_query ($query) or die ('Update failed');
$str = '<center>Page has been updated!</center>';
return $str;
}
function deletetransactions($adid) {
mysql_query ("delete from transactions where id='".$adid."'");
}
function pending_support () {
$bareQuery = "select * from support where ticketstatus = 'Open' and membertype = 'member' and type = 'new' and span = '1'";
$queryall = $bareQuery.$sorted;
$resultall = MYSQL_QUERY($queryall);
$numberall = mysql_num_rows($resultall);
if ($numberall==0) {
echo 'No Support Tickets Waiting Your Reply.<br>';
}
else echo "There Are <b>$numberall</b> Support Tickets Waiting Your Reply, <a href=helpdesk.php><b>Click Here</b></a>.<br>";
}
function show_sales_stats () {
$sql = mysql_query("SELECT * FROM monthly_income WHERE time='".strtotime(date('Y-m-01'))."'");
if(@mysql_num_rows($sql)) {
$info = mysql_fetch_array($sql);
$income = $info['income'];
$commission = round($info['commission'],2);
}else {
$income = 0;
$commission = 0;
}
echo "Total Sales This Month: $".$income."<br>Commissions Earned: $".$commission." <br>Profit: $".($income-$commission).'<br><br>';
$sql = mysql_query("SELECT * FROM monthly_income WHERE time!='".strtotime(date('Y-m-01'))."' ORDER BY time DESC");
if(@mysql_num_rows($sql)) {
echo "Previous months<br><select name=\"profit\">";
while($each = mysql_fetch_array($sql)) {
echo '<option>'.date('F Y',$each['time'])." &nbsp;&nbsp; Profit: $".($each['income']-round($each['commission'],2)).'</option>';
}
echo '</select><br><br><br>';
}
}
function avgsignuprate () {
global $fonttype,$fontcolour,$basecolour,$nav_bg,$contrastcolour;
expandable();
;echo '            <table align=center width=614 bgcolor=#000000 border=0 cellpadding=2 cellspacing=1>
<tr>
<td colspan=3 bgcolor="';echo $nav_bg;;echo '"> 
<div style="text-align:left;width:75%;font-size:12px;float:left;font-weight: bold;">View Avg Signup Rate  [<a title="show/hide" id="asr_link" href="javascript: void(0);" onclick="toggle(this, \'asr\');"  style="text-decoration: strong; color: #000000; ">-</a>]</div>
</td>
</tr>
</table>
';echo openchart('asr');;echo '            <table align=center width=600 bgcolor=#000000 border=0 cellpadding=1 cellspacing=1>
<tr>
<td bgcolor="#FFFFFF">
';echo "<div id=\"displayasr\">";;echo '    <table width=70% align=center border=0 cellpadding=2 cellspacing=2>
<tr>
<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Date</font></center></td>
<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Signups</font></center></td>

</tr>
';
$sql = mysql_query('SELECT joindate FROM members');
$sites = array();
while($each = mysql_fetch_array($sql)) {
$sites[$each['joindate']]++;
}
krsort($sites);
$total=0;
foreach($sites as $date =>$signups) {
$total=$total+$signups;
;echo '  		<tr>
<td bgcolor="';echo $basecolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $date;;echo '</font></center></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $signups;;echo '</font></center></td>
</tr>
';}
echo '</table>';
$firstday = @mysql_result(mysql_query('SELECT joindate FROM members WHERE 1 ORDER BY joindate ASC LIMIT 1'),0);
echo '<center>Average signup rate: '.number_format($total/(round((time()-strtotime($firstday))/24/60/60)),2).'</center><br><br>';
echo '</font></td></tr></table></div></div>';
echo chartclose('asr');
}
function avgloginrate () {
global $fonttype,$fontcolour,$basecolour,$nav_bg,$contrastcolour;
expandable();
;echo '            <table align=center width=614 bgcolor=#000000 border=0 cellpadding=2 cellspacing=1>
<tr>
<td colspan=3 bgcolor="';echo $nav_bg;;echo '"> 
<div style="text-align:left;width:75%;font-size:12px;float:left;font-weight: bold;">View Avg Login Rate  [<a title="show/hide" id="alr_link" href="javascript: void(0);" onclick="toggle(this, \'alr\');"  style="text-decoration: strong; color: #000000; ">-</a>]</div>
</td>
</tr>
</table>
';echo openchart('alr');;echo '            <table align=center width=600 bgcolor=#000000 border=0 cellpadding=1 cellspacing=1>
<tr>
<td bgcolor="#FFFFFF">
';echo "<div id=\"displayalr\">";;echo '<table width=70% align=center border=0 cellpadding=2 cellspacing=2>
<tr>
<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Date</font></center></td>
<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Logins</font></center></td>
</tr>
';
$sql = mysql_query('SELECT date FROM logins');
$sites = array();
while($each = mysql_fetch_array($sql)) {
$sites[$each['date']]++;
}
krsort($sites);
$total=0;
foreach($sites as $date =>$logins) {
$total=$total+$logins;
;echo '  	<tr>
<td bgcolor="';echo $basecolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $date;;echo '</font></center></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $logins;;echo '</font></center></td>
</tr>
';}
echo '</table>';
$firstday = @mysql_result(mysql_query('SELECT date FROM logins WHERE 1 ORDER BY date ASC LIMIT 1'),0);
echo '<center>Average login rate: '.number_format($total/(round((time()-strtotime($firstday))/24/60/60)),2).'</center><br><br>';
echo '</font></td></tr></table></div></div>';
echo chartclose('alr');
}
function addadtomember () {
echo '<center><H2>Add ads to a specific user</H2></center>';
if($_POST['action'] == 'addads') {
$userid = $_POST['userid'];
$type = $_POST['type'];
$max = $_POST['max'];
$quantity = $_POST['quantity'];
addads ($userid,$max,$type,$quantity);
}
;echo '          <p>
<form method="POST">
<input type="hidden" name="action" value="addads">
<table border=0 width=350 bgcolor=#000000><tr><td>
<table border=0 width=350 bgcolor="#FFFFFF" cellpadding=5 cellspacing=0>
<tr><td colspan=2 align=center><b>Add blank ads to a users account</b></td></tr>
<tr><td width=110 align=right>Type:</td>
<td><select name="type">
<option>CHOOSE AD TYPE</option>
<option>468x60 Banner Ad</option>
<option>125x125 Banner Ad</option>
<option>Text Link Ad</option>
</select>
</td></tr>
<tr><td width=110 align=right>Quantity:</td><td><input type="text" name="quantity"></td></tr>
<tr><td width=110 align=right>Userid:</td><td><input type="text" name="userid"></td></tr>
<tr><td width=110 align=right>Max Imp/Click:</td><td><input type="text" name="max"></td></tr>
<tr><td>&nbsp;</td><td><input type="submit" value="Add"></td></tr>
</table>
</td></tr></table>
</form>
</p>



';
}
function deleteadminsponsor($adid) {
$query = "DELETE FROM adminsites WHERE id= '".$adid."'";
$result = mysql_query($query) or die (mysql_error());
$str= '<p align=center>The site has been deleted.</p>';
return $str;
}
function editadminsponsor($sponsorminp,$sponsormaxp) {
$query = "update settings set setting='".$sponsorminp."' where name='sponsormin'";
$result = mysql_query($query) or die (mysql_error());
$query2 = "update settings set setting='".$sponsormaxp."' where name='sponsormax'";
$result2 = mysql_query($query2) or die (mysql_error());
}
function addadminsponsor($adminurl) {
$query = "INSERT INTO adminsites (id,url) VALUES ('','".$adminurl."')";
$result = mysql_query($query) or die (mysql_error());
$str= '<p align=center>The site has been added.</p>';
return $str;
}
function selectadminsite() {
$site = 'select * from adminsites order by id';
$site1 = mysql_query($site);
return $site1;
}
function cumulativequery($type) {
$query = "SELECT * FROM members where $type>1 ORDER BY `members`.`$type` DESC";
$result = mysql_query($query);
return $result;
}
function defaultcumulative() {
$query = 'SELECT * FROM members where textad1_clicks>1 ORDER BY `members`.`textad1_clicks` DESC';
$result = mysql_query($query);
return $result;
}
function dailyquery($type) {
$query = "SELECT * FROM members where $type>1 ORDER BY `members`.`$type` DESC";
$result = mysql_query($query);
return $result;
}
function defaultdaily() {
$query = 'SELECT * FROM members where textad_clicks>1 ORDER BY `members`.`textad_clicks` DESC';
$result = mysql_query($query);
return $result;
}
function clickstatsum ($type) {
$totaltype='total_'.$type.'';
$TotQuery = "SELECT SUM($type) as $totaltype FROM members";
$Row = mysql_fetch_array(mysql_query($TotQuery));
$total = $Row[$totaltype];
return $total;
}
function memberclicksum ($userid) {
$getuserdata = mysql_query("SELECT banner1_clicks, button1_clicks, textad1_clicks FROM members where userid='".$userid."'");
$banner1_clicks = mysql_result($getuserdata,0,'banner1_clicks');
$button1_clicks = mysql_result($getuserdata,0,'button1_clicks');
$textad1_clicks = mysql_result($getuserdata,0,'textad1_clicks');
$total = $banner1_clicks+$button1_clicks+$textad1_clicks;
return $total;
}
function pending_cashout () {
$query = 'select * from cashoutrequests where amountrequested>0.00';
$result = mysql_query ($query);
$numrows = @ mysql_num_rows($result);
if ($numrows <1) {
echo 'No Cash Out Requests Pending.<br><br>';
}else echo "<a href=\"cashoutrequests.php\">Cash Out Requests Pending.</a><br><br>";
}
function add_pdcommission ($paid) {
$commtoadd = number_format($paid ,2);
mysql_query("update lifetimeadstats set pdcommission=pdcommission+$commtoadd");
}
function cashoutrequest () {
extract($GLOBALS);
$os0 = $_POST['option_selection1'];
$os1 = $_POST['option_selection2'];
$custom = $_POST['custom'];
if (($os0 != '') and ($os1 != '') and ($custom != ''))
{
$payid = $os1;
$payamount = $custom;
$payuserid = $os0;
$q2 = "select * from members where userid=\"$payuserid\"";
$r2 = mysql_query($q2);
$rows2 = mysql_num_rows($r2);
if ($rows2 >0)
{
$paycommission = mysql_result($r2,0,'commission');
if ($paycommission >= $payamount)
{
$q3 = 'update members set commission=commission-'.$payamount." where userid=\"$payuserid\"";
$r3 = mysql_query($q3);
$q4 = "insert into regularpayouts (userid,paid,datepaid,description) values (\"$payuserid\",\"$payamount\",NOW(),\"Regular Commission Payout\")";
$r4 = mysql_query($q4);
add_pdcommission ($payamount);
mysql_query("INSERT INTO account_ledger VALUES ('id','".$userid."','Commissions Paid','".time()."','$$payamount')");
mysql_query("INSERT INTO transactions VALUES ('id','".$userid."','Commissions Paid','".time()."','$$payamount')");
$q7 = "DELETE FROM cashoutrequests where id=\"$payid\"";
$r7 = mysql_query($q7);
}
if ($paycommission <$payamount)
{
$q3 = "update members set commission=0 where userid=\"$payuserid\"";
$r3 = mysql_query($q3);
if ($paycommission >0)
{
$q4 = "insert into regularpayouts (userid,paid,datepaid,description) values (\"$payuserid\",\"$paycommission\",NOW(),\"Regular Commission Payout\")";
$r4 = mysql_query($q4);
add_pdcommission ($paycommission);
mysql_query("INSERT INTO account_ledger VALUES ('id','".$userid."','Commissions Paid','".time()."','$$payamount')");
mysql_query("INSERT INTO transactions VALUES ('id','".$userid."','Commissions Paid','".time()."','$$payamount')");
}
$q7 = "DELETE FROM cashoutrequests where id=\"$payid\"";
$r7 = mysql_query($q7);
$howmuchlefttopay = $payamount-$paycommission;
}
}
}
$apc_1 = $_GET['apc_1'];
$apc_2 = $_GET['apc_2'];
$apc_3 = $_GET['apc_3'];
if (($apc_1 != '') and ($apc_2 != '') and ($apc_3 != ''))
{
$payid = $apc_1;
$payamount = $apc_2;
$payuserid = $apc_3;
$q2 = "select * from members where userid=\"$payuserid\"";
$r2 = mysql_query($q2);
$rows2 = mysql_num_rows($r2);
if ($rows2 >0)
{
$paycommission = mysql_result($r2,0,'commission');
if ($paycommission >= $payamount)
{
$q3 = 'update members set commission=commission-'.$payamount." where userid=\"$payuserid\"";
$r3 = mysql_query($q3);
$q4 = "insert into regularpayouts (userid,paid,datepaid,description) values (\"$payuserid\",\"$payamount\",NOW(),\"Regular Commission Payout\")";
$r4 = mysql_query($q4);
add_pdcommission ($payamount);
mysql_query("INSERT INTO account_ledger VALUES ('id','".$userid."','Commissions Paid','".time()."','$$payamount')");
mysql_query("INSERT INTO transactions VALUES ('id','".$userid."','Commissions Paid','".time()."','$$payamount')");
$q7 = "DELETE FROM cashoutrequests where id=\"$payid\"";
$r7 = mysql_query($q7);
}
if ($paycommission <$payamount)
{
$q3 = "update members set commission=0 where userid=\"$payuserid\"";
$r3 = mysql_query($q3);
if ($paycommission >0)
{
$q4 = "insert into regularpayouts (userid,paid,datepaid,description) values (\"$payuserid\",\"$paycommission\",NOW(),\"Regular Commission Payout\")";
$r4 = mysql_query($q4);
add_pdcommission ($paycommission);
mysql_query("INSERT INTO account_ledger VALUES ('id','".$userid."','Commissions Paid','".time()."','$$payamount')");
mysql_query("INSERT INTO transactions VALUES ('id','".$userid."','Commissions Paid','".time()."','$$payamount')");
$q7 = "DELETE FROM cashoutrequests where id=\"$payid\"";
$r7 = mysql_query($q7);
}
$howmuchlefttopay = $payamount-$paycommission;
}
}
}
function formatDate($val) {
$arr = explode('-',$val);
return date('M d Y',mktime(0,0,0,$arr[1],$arr[2],$arr[0]));
}
if ($_POST['action'] == 'delete')
{
$id = mres($_POST['id']);
$q = "delete from cashoutrequests where id=\"$id\"";
$r = mysql_query($q);
$show = "<p align=\"center\">Request Deleted</p>";
}
;echo '<table align="center" border="0" width="100%">
<tr>
<td valign="top" align="center"> ';
echo '<p><center>';
echo '<H2>Member Cash Out Requests</H2>';
$query = 'select * from cashoutrequests where amountrequested>0.00 order by id';
$result = mysql_query ($query);
$numrows = @ mysql_num_rows($result);
if ($numrows <1) {
echo '<p><center>No Cash Out Requests Pending.</p></center>';
}
if ($show != '')
{
echo $show;
}
if ($numrows >0)
{
;echo '<br>
<table width=90% border=1 cellpadding=2 cellspacing=0 bgcolor="';echo $admintablebgcolor ;echo '">
<tr>
<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Userid</font></center></td>
';if ($pay_with['payza']) {;echo '<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Payza</font></center></td>
';};echo '';if ($pay_with['paypal']) {;echo '<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">PayPal</font></center></td>
';};echo '<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Amount Requested</font></center></td>
<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Date Requested</font></center></td>
<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Regular Commissions Owing</font></center></td>

<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Already Paid For This Request</font></center></td>
<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Date Paid For This Request</font></center></td>
<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Submit Payment</font></center></td>
<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Delete Request</font></center></td>
</tr>
';
while ($line = mysql_fetch_array($result)) {
$requestid = $line['id'];
$userid = $line['userid'];
$memberpayza = $line['payza'];
$memberpaypal = $line['paypal'];
$amountrequested = $line['amountrequested'];
$regularowed = $line['regularowed'];
$daterequested = $line['daterequested'];
if (($daterequested == '') or ($daterequested == 0))
{
$daterequested = 'N/A';
}
if (($daterequested != '') and ($daterequested != 0))
{
$daterequested = formatDate($daterequested);
}
$paid = $line['paid'];
$lastpaid = $line['lastpaid'];
if (($lastpaid == '') or ($lastpaid == 0))
{
$lastpaid = 'N/A';
}
if (($lastpaid != '') and ($lastpaid != 0))
{
$lastpaid = formatDate($lastpaid);
}
;echo '<tr>
<td bgcolor="#FFFFFF"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">';echo $userid ;echo '</font></center></td>
';if ($pay_with['payza']) {;echo '<td bgcolor="#FFFFFF"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">';echo $memberpayza ;echo '</font></center></td>
';};echo '';if ($pay_with['paypal']) {;echo '<td bgcolor="#FFFFFF"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">';echo $memberpaypal ;echo '</font></center></td>
';};echo '<td bgcolor="#FFFFFF"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">$';echo $amountrequested ;echo '</font></center></td>
<td bgcolor="#FFFFFF"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">';echo $daterequested ;echo '</font></center></td>
<td bgcolor="#FFFFFF>"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">$';echo $regularowed ;echo '</font></center></td>

<td bgcolor="#FFFFFF"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">$';echo $paid ;echo '</font></center></td>
<td bgcolor="#FFFFFF"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">';echo $lastpaid ;echo '</font></center></td>
<td bgcolor="#FFFFFF"><center>&nbsp;
';
if($memberpayza == 'Not Entered') {
$memberpayza = '';
}else {
$memberpayza=$memberpayza;
}
if($memberpaypal == 'Not Entered') {
$memberpaypal = '';
}else {
$memberpaypal=$memberpaypal;
}
if ($memberpayza != '')
{
;echo '<form method="post" action="https://secure.payza.com/checkout" >
<input type="hidden" name="ap_purchasetype" value="item"/> 
<input type="hidden" name="ap_merchant" value="';echo $memberalertpay;;echo '"/> 
<input type="hidden" name="ap_currency" value="USD"/> 
<input type="hidden" name="ap_returnurl" value="';echo $domain;;echo '/admin/cashoutrequests.php?apc_1=';echo $requestid;;echo '&apc_2=';echo $amountrequested;;echo '&apc_3=';echo $userid;;echo '"/> 
<input type="hidden" name="ap_cancelurl" value="';echo $domain;;echo '/admin/cashoutrequests.php"/> 
<input type="hidden" name="ap_itemname" value="';echo $sitename;;echo ' Pay Commission ';echo $userid;;echo '"/> 
<input type="hidden" name="ap_quantity" value="1"/> 
<input type="hidden" name="apc_1" value="';echo $requestid;;echo '">
<input type="hidden" name="apc_2" value="';echo $amountrequested;;echo '">
<input type="hidden" name="apc_3" value="';echo $userid;;echo '">
<input type="hidden" name="ap_amount" value="';echo $amountrequested;;echo '"/> 
<input type="image" name="ap_image" src="';echo $domain ;echo '/images/payzasm.gif" alt="APayza" height="28"/>
</center>
</form>
';
}
;echo '';
if ($memberpaypal != '')
{
;echo '<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="';echo $memberpaypal;;echo '">
<input type="hidden" name="item_name" value="';echo $sitename;;echo ' Pay Commission ';echo $userid;;echo '">
<input type="hidden" name="on0" value="User ID">
<input type="hidden" name="os0" value="';echo $userid;;echo '">
<input type="hidden" name="on1" value="ID">
<input type="hidden" name="os1" value="';echo $requestid;;echo '">
<input type="hidden" name="custom" value="';echo $amountrequested;;echo '">
<input type="hidden" name="amount" value="';echo $amountrequested;;echo '">
<input type="hidden" name="undefined_quantity" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="notify_url" value="';echo $domain;;echo '/admin/cashoutrequests.php">
<input type="hidden" name="return" value="';echo $domain;;echo '/admin/index.php">
<input type="hidden" name="cancel" value="';echo $domain;;echo '/admin/index.php">
<input type="hidden" name="currency_code" value="USD">
</form>

';
}
;echo '
<center><a href="cashoutrequests.php?apc_1=';echo $requestid;;echo '&apc_2=';echo $amountrequested;;echo '&apc_3=';echo $userid;;echo '"><font size=1><b>Mark As Paid</b></font></a></center>

</td>
';
;echo '
<form method=POST action="cashoutrequests.php">
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">
<input type="hidden" name="action" value="delete">
<input type="hidden" name="id" value="';echo $requestid;;echo '">
<input type="submit" value="Delete">
</center>
</td></form> 
</form>
</tr>
';
}
echo '</table></center>';
}
echo '</td></tr></table>';
}
function selectmember($userid) {
$query = "SELECT * FROM members where userid='".$userid."'";
$result = mysql_query($query);
return $result;
}
function showreferrals ($userid) {
$sortby = $_GET['sortby'];
if(!$sortby) $sortby = 'joindate';
$sql = mysql_query("SELECT * FROM members WHERE referid='".$userid."' ORDER BY $sortby ASC, id ASC");
if(@mysql_num_rows($sql)) {
;echo '<div style="width: 675px; height: 400px; padding: 2px; overflow:auto; border-style: solid; border-size: 1px; border-color: #000000; background: #ffffff;"><table bgcolor="#000000" border=0 cellpadding=3><tr bgcolor="#CCCCCC"><th><a href="commission.php?pageid=showreferrals&id=';echo $userid;;echo '&sortby=userid">Userid</a></th><th><a href="commission.php?pageid=showreferrals&id=';echo $_GET['id'];;echo '&sortby=userid">Name</a></th><th><a href="commission.php?pageid=showreferrals&id=';echo $_GET['id'];;echo '&sortby=contact_email">Email</a></th><th><a href="commission.php?pageid=showreferrals&id=';echo $_GET['id'];;echo '&sortby=ip">IP Address</a></th><th><a href="commission.php?pageid=showreferrals&id=';echo $_GET['id'];;echo '&sortby=referrer">Came from</a></th><th><a href="commission.php?pageid=showreferrals&id=';echo $_GET['id'];;echo '&sortby=joindate">Date joined</a></th><th>Clicks</th><th><a href="commission.php?pageid=showreferrals&id=';echo $_GET['id'];;echo '&sortby=lastlogin">Login</a></th></tr>';
while($each = mysql_fetch_array($sql)) {
echo "<tr bgcolor=\"#FFFFFF\"><td>".$each['userid'].'</td><td>'.$each['name'].'</td><td>'.$each['contact_email'].'</td><td>'.$each['ip'].'</td><td>'.$each['referrer'].'</td><td>'.$each['joindate'].'</td><td>'.memberclicksum ($each['userid']).'</td><td>';
if($each['lastlogin']) echo 'Yes';
else echo 'No';
echo '</td></tr>';
}
echo '</table></div>';
}else echo "That member doesn't have any referral.";
echo '</table></center>';
}
function registration_type () {
extract($GLOBALS);
if($_POST['action'] == 'changemode') {
$reg_domain	= $_POST['domainname'];
$query = 'select * from bandomain_settings';
$result = mysql_query( $query )
or die( 'Connection error. Check database settings!');
$array = mysql_fetch_array($result);
$mode = $array['type'];
if( $mode == 'allow')
{
$query = "update bandomain_settings set type='reject'";
$result = mysql_query( $query )
or die( 'Connection Error. Check database settings!');
}
if( $mode == 'reject')
{
$query = "update bandomain_settings set type='allow'";
$result = mysql_query( $query )
or die( 'Connection Error. Check database settings!');
}
}
if($_POST['action'] == 'adddomain') {
$reg_domain	= $_POST['domainname'];
$query = 'select * from bandomain_settings';
$result = mysql_query( $query )
or die( 'Connection error. Check database settings!');
$array = mysql_fetch_array($result);
$mode = $array['type'];
if( $mode == 'allow')
{
$query = "insert into allowdomains (domain) values ('".$reg_domain."')";
$result = mysql_query( $query )
or die( 'Connection Error. Check database settings!');
}
if( $mode == 'reject')
{
$query = "insert into rejected_domains (domain) values ('".$reg_domain."')";
$result = mysql_query( $query )
or die( 'Connection Error. Check database settings!');
}
}
if($_POST['action'] == 'deletedomain') {
$reg_domain	= $_POST['domainname'];
$query = 'select * from bandomain_settings';
$result = mysql_query( $query )
or die( 'Connection error. Check database settings!');
$array = mysql_fetch_array($result);
$mode = $array['type'];
if( $mode == 'allow')
{
$query = "delete from allowdomains where domain='".$reg_domain."'";
$result = mysql_query( $query )
or die( 'Connection Error. Check database settings!');
}
if( $mode == 'reject')
{
$query = "delete from rejected_domains where domain='".$reg_domain."'";
$result = mysql_query( $query )
or die( 'Connection Error. Check database settings!');
}
}
$query = 'select * from bandomain_settings';
$result = mysql_query( $query )
or die( 'Connection error. Check database settings!');
$array = mysql_fetch_array($result);
$mode = $array['type'];
if( $mode == 'allow')
{
$query2 = 'select * from allowdomains';
$result2 = mysql_query( $query2 )
or die( 'Connection error. Check database settings!(2)');
$array2 = mysql_fetch_array($result2);
}
else if( $mode == 'reject')
{
$query2 = 'select * from rejected_domains';
$result2 = mysql_query( $query2 )
or die( 'Connection error. Check database settings!(2)');
$array2 = mysql_fetch_array($result2);
}
$rows = mysql_num_rows( $result2 );
$reg_domain = $array2['domain'];
;echo '	
<center><H2>Email Use Preferences</H2></center>

';
if( $mode == 'allow')
{
echo( "You're currently running in &quot;<b>REQUIRED</b>&quot;.<br>Members can only register on your site if they use one of the below e-mail addresses.<br>");
;echo '			<br><form method="POST">
<input type="hidden" name="action" value="changemode">
<input type="submit" value="Change to BAN Mode">
</form><br>
';
}
else if( $mode == 'reject')
{
echo( "You're currently running in &quot;<b>BAN</b>&quot;.<br>Members can only register on your site if they use an e-mail address that is not listed below.<br>");
;echo '			<br><form method="POST">
<input type="hidden" name="action" value="changemode">
<input type="submit" value="Change to REQUIRED Mode">
</form><br>
';
}
;echo '	
<br><br><br>Add a domain:
<form method="POST">
<input type="text" name="domainname" value=""><br>
<input type="hidden" name="action" value="adddomain">
<input type="submit" value="Add Domain">
</form><br>

<b>Note:</b><br>When adding a domain use only the domain name (bandomain.com)<br><br>
<br>

';
if( $rows != 0 )
{
;echo '		';
if( $mode == 'allow')
{
echo( '<b>Currently people can only join if they use one of the following domains:</b><br><br>');
}
else if( $mode == 'reject')
{
echo( '<b>Currently people can only join if they use a domain not listed below:</b><br><br>');
}
;echo '		
<table cellpadding=\'2px\' cellspacing=\'2px\' border=\'0\' align=\'center\' valign=\'middle\'>


<tr>
<td valign="middle" bgcolor="';echo $contrastcolour;;echo '">
<center>
<font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Domain Name</font>
</center>
</td>

<td valign="middle" bgcolor="';echo $contrastcolour;;echo '">
<center>
<font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Delete</font>
</center>
</td>
</tr>

<!-- Show the first row -->
<tr>
<td valign="middle" bgcolor="';echo $basecolour;;echo '">
<center>
';echo( $reg_domain );;echo '					</center>
</td>

<td valign="middle" bgcolor="';echo $basecolour;;echo '">
<center>
<form method="POST">
<input type="hidden" name="domainname" value="';echo( $reg_domain );;echo '">
<input type="hidden" name="action" value="deletedomain">
<input type="submit" value="Delete Entry">
</form>
</center>
</td>
</tr>

';
while( $line = mysql_fetch_array( $result2 ) )
{
$reg_domain = $line['domain'];
;echo '				<tr>
<td valign="middle" bgcolor="';echo $basecolour;;echo '">
<center>
';echo( $reg_domain );;echo '						</center>
</td>

<td valign="middle" bgcolor="';echo $basecolour;;echo '">
<center>
<form method="POST">
<input type="hidden" name="domainname" value="';echo( $reg_domain );;echo '">
<input type="hidden" name="action" value="deletedomain">
<input type="submit" value="Delete Entry">
</form>
</center>
</td>
</tr>
';
}
;echo '		</table> <!-- End the table of e-mails -->

';
}
else
{
;echo '		<H3><font color=\'red\'><b>You don\'t have any domains added.<br>Please use the form above to add a domain.</b></font></H3>
';
}
;echo '<br><br>
<center><H2>User Exit Settings</H2></center>

';
if($_POST['action'] == 'set') {
$options = mysql_query ("select * from exited_options where id='1'");
$array = mysql_fetch_array($options);
$scriptactive = $array['exit_active'];
if($scriptactive == 1)
{
$query1 = "update exited_options set exit_active='0'";
$result1 = mysql_query ($query1);
}
else
{
$query1 = "update exited_options set exit_active='1'";
$result1 = mysql_query ($query1);
}
}
if($_POST['action'] == 'store') {
$options = mysql_query ("select * from exited_options where id='1'");
$array = mysql_fetch_array($options);
$logexit = $array['log_exit'];
if($logexit == 1)
{
$query1 = "update exited_options set log_exit='0'";
$result1 = mysql_query ($query1);
}
else
{
$query1 = "update exited_options set log_exit='1'";
$result1 = mysql_query ($query1);
}
}
if($_POST['action'] == 'notify') {
$options = mysql_query ("select * from exited_options where id='1'");
$array = mysql_fetch_array($options);
$joinemail = $array['join_email'];
if($joinemail == 1)
{
$query1 = "update exited_options set join_email='0'";
$result1 = mysql_query ($query1);
}
else
{
$query1 = "update exited_options set join_email='1'";
$result1 = mysql_query ($query1);
}
}
if($_POST['action'] == 'notify2') {
$options = mysql_query ("select * from exited_options where id='1'");
$array = mysql_fetch_array($options);
$exitemail = $array['exit_email'];
if($exitemail == 1)
{
$query1 = "update exited_options set exit_email='0'";
$result1 = mysql_query ($query1);
}
else
{
$query1 = "update exited_options set exit_email='1'";
$result1 = mysql_query ($query1);
}
}
if($_POST['action'] == 'admin') {
$exit_adminemail = stripslashes($_POST['email']);
$query1 = "update exited_options set adminemail='$exit_adminemail'";
$result1 = mysql_query ($query1);
}
if($_POST['action'] == 'deleteip') {
$mip = $_POST['ip'];
$options = mysql_query ("select * from exited_bannedips where ip='$mip'");
$array = mysql_fetch_array($options);
$query1 = "delete from exited_bannedips where ip='$mip'";
$result = mysql_query ($query1);
echo '<center>The IP '.$mip.' has been unbanned.</center><br><br>';
}
$mip = $_GET['showmip'];
$emip = $_POST['ipaddress'];
if($_POST['action'] == 'banip') {
if($emip == '')
{
;echo 'There was no ip address inputed no action performed<br><br>

Click <a href="/">here</a> to try again.';
exit;
}
$options = mysql_query ("select * from exited_bannedips where ip='$emip'");
$numrows = mysql_num_rows($options);
if ($numrows>0)
{
;echo 'The IP ';$emip ;echo ' <font color="red">is already banned</font>.<br><br>

Click <a href="/">here</a> to go back.';
exit;
}
$query1 = "insert into exited_bannedips (ip) values ('$emip')";
$result1 = mysql_query ($query1);
;echo '<center>The IP: ';echo $emip;;echo ' <font color=black>has been banned</font>.</center><br><br>

';
}
$query = 'SELECT * FROM `exited` ORDER BY `exited`.`deleted` ASC';
$result = mysql_query ($query)
or die ('Query failed');
$num_rows = mysql_num_rows($result);
;echo '<table>
<tr>
<td valign="top" align="center">
';
echo "<font size=4 face='$fonttype' color='$fontcolour'><p><center>";
$options = mysql_query ("select * from exited_options where id='1'");
$array = mysql_fetch_array($options);
$scriptactive = $array['exit_active'];
$joinemail = $array['join_email'];
$exitemail = $array['exit_email'];
$email = $array['adminemail'];
$logexit = $array['log_exit'];
echo "<font size=3 face='$fonttype' color='$fontcolour'>"
;echo 'Activate or Deactivate<br>';
if($scriptactive == 1)
{
;echo '			<font size=2>The script is currently <font color=green><b>ACTIVE</b></font>.</font><br>
<form method="POST"">
<input type="hidden" name="action" value="set">
<input type="submit" value="Deactivate">
</form>
';
}
else
{
;echo '			<font size=2>The script is currently <font color=red><b>INACTIVE</b></font>!</font><br>
<form method="POST">
<input type="hidden" name="action" value="set">
<input type="submit" value="Activate">
</form>
<font size=2><font color=red>NOTE: All other functions are overridden by the above setting!</font><br>
';
}
echo "<font size=3 face='$fonttype' color='$fontcolour'>"
;echo '<br><Do you want to store the leaving members information?';
if($logexit == 1)
{
;echo '			<br><font size=2>You\'re currently in the  <font color=green><b>STORE</b></font> mode.</font><br>
<form method="POST">
<input type="hidden" name="action" value="store">
<input type="submit" value="Stop Storing">
</form>
';
}
else
{
;echo '			<br><font size=2>You are currently in the <font color=red><b>NOT STORING</b></font> mode.</font><br>
<form method="POST">
<input type="hidden" name="action" value="store">
<input type="submit" value="Store">
</form>
';
}
echo "<font size=2 face='$fonttype' color='$fontcolour'>"
;echo '<br>Do you want to receive e-mail when a member joins?';
if($joinemail == 1)
{
;echo '			<br><font size=2>You\'re currently <font color=green><b>RECEIVING</b></font> e-mail when someone joins.</font><br>
<form method="POST">
<input type="hidden" name="action" value="notify">
<input type="submit" value="Stop Notification">
</form>
';
}
else
{
;echo '			<br><font size=2>You are currently <font color=red><b>NOT RECEIVING</b></font> e-mail when someone joins!</font><br>
<form method="POST">
<input type="hidden" name="action" value="notify"> 
<input type="submit" value="Start Notification">
</form>
';
}
echo "<font size=2 face='$fonttype' color='$fontcolour'>"
;echo 'Do you want to receive e-mail when a member leaves?';
if($exitemail == 1)
{
;echo '			<br><font size=2>You\'re currently <font color=green><b>RECEIVING</b></font> e-mail when someone leaves.</font><br>
<form method="POST">
<input type="hidden" name="action" value="notify2">
<input type="submit" value="Stop Notification">
</form>
';
}
else
{
;echo '			<br><font size=2>You are currently <font color=red><b>NOT RECEIVING</b></font> e-mail when someone leaves!</font><br>
<form method="POST">
<input type="hidden" name="action" value="notify2">  
<input type="submit" value="Start Notification">
</form>
';
}
echo "<font size=2 face='$fonttype' color='$fontcolour'>"
;echo '<br>Please enter the email below to send notifications to.';
if(!$email)
{
;echo '			<br><font size=2>You have <font color=red><b>NOT STORED</b></font> an e-mail adress yet!</font><br>
<form method="post">
<input type="hidden" name="action" value="admin"> 
<input type="text" name="email"><br>
<input name="submit" value="Submit E-mail" type="submit">
</div>
</div>
</form>
';
}
else
{
;echo '			<br><font size=2>The current e-mail is <font color=green><b>';echo($email) ;echo '</b></font></font><br>
<form method="post">
<input type="hidden" name="action" value="admin">
<input type="text" name="email"><br>
<input name="submit" value="Change E-mail" type="submit">			</form>

';
}
echo "<font size=2 face='$fonttype' color='$fontcolour'><p><center>";
;echo '			Enter the IP Adress to ban
<center>
<form method="POST">
<input type="hidden" name="action" value="banip"> 
<font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">
<input type="text" name="ipaddress" maxLength="50" size="40" value=""><br>
<input type="submit" value="Ban IP">
</form>
</font>
</center><br>


Click to show the list of banned IP\'s<br>
(You can also unban IP\'s in this list)
<center>
<form method="POST">
<input type="submit" name="action" value="Show the banned IP list">
</form>
</font>
</center>
<br><br>
';
if($_POST['action'] == 'Show the banned IP list') {
$query = 'SELECT * FROM `exited_bannedips` ORDER BY `exited_bannedips`.`ip` ASC';
$result = mysql_query ($query)
or die ('Query failed x');
$num_rows = mysql_num_rows($result);
;echo '<table width=300>
<tr>

<td valign="top" align="center"><br><br> ';
echo "<font size=2 face='$fonttype' color='$fontcolour'><p><center>";
echo '<center><p><b>';
echo "$num_rows Results found<br><br>";
echo '</center></p></b>';
;echo '		<center>
<table width=100% border=0 bgcolor=#000000 cellpadding=2 cellspacing=2>


<tr>
<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"> IP Address </font></center></td>
<td bgcolor="';echo $contrastcolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"> Unban IP </font></center></td>
</tr>
';
while ($line = mysql_fetch_array($result))
{
$ip = $line['ip'];
;echo '			<tr>
<td bgcolor="';echo $basecolour;;echo '"><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $ip;;echo '</font></center></td>
<td valign="middle" bgcolor="';echo $basecolour;;echo '"><center><br>
<form method="POST">
<input type="hidden" name="action" value="deleteip"> 
<input type="hidden" name="ip" value="';echo $ip ;echo '">
<input type="submit" value="Unban IP">
</form> </center>
</td>
';
}
;echo '		</center>
</td>
</tr>
</table></td>
</tr>
</table>
';
}
echo '</td></tr></table>';
}
function resignups_admin () {
extract($GLOBALS);
$action = '';
if ( isset( $_GET['action'] ) ) {
$action = $_GET['action'];
}
if ( isset( $_POST['action'] ) ) {
$action = $_POST['action'];
}
$actionid = '';
if ( isset( $_GET['id'] ) ) {
$actionid = $_GET['id'];
}
if ( isset( $_POST['id'] ) ) {
$actionid = $_POST['id'];
}
if ($action=='ri'&&$actionid!='') {
DisplayMemberForAction("<font color=\"#330099\">Reinstate</font> Member",'Confirm Reinstate',$actionid,$contrastcolour,$basecolour,$fonttype,$fontcolour);
}else if ($action=='pb'&&$actionid!='') {
DisplayMemberForAction("<font color=\"red\">Permanently Ban</font> Member",'Confirm Permanent Ban',$actionid,$contrastcolour,$basecolour,$fonttype,$fontcolour);
;echo '
';
}else {
if (($action=='Confirm Reinstate'||$action=='Confirm Permanent Ban') &&$actionid!='') {
if ($action=='Confirm Reinstate') {
$query = 'DELETE FROM member_deletes WHERE id='.$actionid.';';
}else {
$query = "UPDATE member_deletes SET reinstate_date='9999-12-31' WHERE id=".$actionid.';';
}
$result = mysql_query ($query) or die ('Query failed');
}
$query = 'SELECT * FROM member_deletes ORDER by email;';
$result = mysql_query ($query) or die ('Query failed');
$num_rows = mysql_num_rows($result);
;echo '        <font size="2" face="';echo $fonttype ;echo '" color="';echo $fontcolour ;echo '"><p><center>
<center>
<p>
<b>';echo $num_rows ;echo ' Deleted Members</b>
</p>
</center>
';
if (($action=='Confirm Reinstate'||$action=='Confirm Permanent Ban') &&$actionid!='') {
;echo '        <font size="2" face="';echo $fonttype ;echo '" color="';echo $fontcolour ;echo '"><p><center>
<center>
<p>
';
if ($action=='Confirm Reinstate') {
;echo ' <b>* Member Reinstated *</b> ';
}else {
;echo ' <b>* Member Permanently Banned *</b> ';
}
;echo '          </p>
</center>
';
}
CreateListHeader(true,$contrastcolour,$fonttype,$fontcolour);
;echo ' <tbody> ';
while ($mem_del_rec = mysql_fetch_array($result)) {
CreateListRow($mem_del_rec,true,$basecolour,$fonttype,$fontcolour);
}
;echo '					</tbody>
</table>
';
}
}
Function CreateListHeader($showactions,$contrastcolour,$fonttype,$fontcolour) {
extract($GLOBALS);
;echo '        <table width=90% border="0" cellpadding="2" cellspacing="1">
<thead>
';if ($showactions) {;echo '            <tr>
<td colspan="10" bgcolor="#fdfdc9" align="right">
<font size=1 face="';echo $fonttype;;echo '">
<span style="vertical-align:middle;font-weight:bold;">Action Key:&nbsp;</span>
<img align="absmiddle" src="../images/reinstate.png" border="0"><span style="vertical-align:middle;"> - Reinstate Member&nbsp;&nbsp;&nbsp;</span>
<img align="absmiddle" src="../images/permban.png" border="0"><span style="vertical-align:middle;"> - Permanently Ban Member</span>
</font>
</th>
</tr>
';};echo '            <tr>
<th rowspan="2" bgcolor="';echo $contrastcolour;;echo '"><center><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Date<br>Deleted</font></center></th>
<th rowspan="2" bgcolor="';echo $contrastcolour;;echo '"><center><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Deleted<br>By</font></center></th>
<th rowspan="2" bgcolor="';echo $contrastcolour;;echo '"><center><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Email</font></center></th>
<th rowspan="2" bgcolor="';echo $contrastcolour;;echo '"><center><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">IP</font></center></th>
<th rowspan="2" bgcolor="';echo $contrastcolour;;echo '"><center><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Reinstate<br>Date</font></center></th>
<th colspan="2" bgcolor="';echo $contrastcolour;;echo '"><center><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Re-signup Attempts<br>with same Email</font></center></th>
<th colspan="2" bgcolor="';echo $contrastcolour;;echo '"><center><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Re-signup Attempts<br>with same IP</font></center></th>
';if ($showactions) {;echo '              <th rowspan="2" bgcolor="';echo $contrastcolour;;echo '"><center><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Action</font></center></th>
';};echo '            </tr>
<tr>
<th bgcolor="';echo $contrastcolour;;echo '"><center><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Number Of</font></center></th>
<th bgcolor="';echo $contrastcolour;;echo '"><center><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Last</font></center></th>
<th bgcolor="';echo $contrastcolour;;echo '"><center><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Number Of</font></center></th>
<th bgcolor="';echo $contrastcolour;;echo '"><center><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Last</font></center></th>
</tr>
</thead>
';
}
Function CreateListRow($mem_del_rec,$showactions,$basecolour,$fonttype,$fontcolour) {
extract($GLOBALS);
$recid = $mem_del_rec['id'];
$date_deleted = date('m-d-Y',strtotime($mem_del_rec['date_deleted']));
$deleted_by = $mem_del_rec['deleted_by'];
$email = $mem_del_rec['email'];
$ip = $mem_del_rec['ip'];
$reinstate_date = $mem_del_rec['reinstate_date'];
if ($reinstate_date=='9999-12-31') {
$reinstate_date = 'Permanent Ban';
}else {
$reinstate_date = date('m-d-Y',strtotime($reinstate_date));
}
$email_num_attempts = $mem_del_rec['email_resignup_attempts'];
if ($email_num_attempts==0) {
$email_num_attempts = '-';
}
$email_last_attempt = $mem_del_rec['email_last_attempted'];
if ($email_last_attempt==''||$email_last_attempt=='0000-00-00') {
$email_last_attempt = '-';
}else {
$email_last_attempt = date('m-d-Y',strtotime($email_last_attempt));
}
$ip_num_attempts = $mem_del_rec['ip_resignup_attempts'];
if ($ip_num_attempts==0) {
$ip_num_attempts = '-';
}
$ip_last_attempt = $mem_del_rec['ip_last_attempted'];
if ($ip_last_attempt==''||$ip_last_attempt=='0000-00-00') {
$ip_last_attempt = '-';
}else {
$ip_last_attempt = date('m-d-Y',strtotime($ip_last_attempt));
}
;echo '            <tr>
<td bgcolor="';echo $basecolour;;echo '"><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $date_deleted;;echo '</font></center></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $deleted_by;;echo '</font></center></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $email;;echo '</font></center></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $ip;;echo '</font></center></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $reinstate_date;;echo '</font></center></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $email_num_attempts;;echo '</font></center></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $email_last_attempt;;echo '</font></center></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $ip_num_attempts;;echo '</font></center></td>
<td bgcolor="';echo $basecolour;;echo '"><font size=1 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '"><center>';echo $ip_last_attempt;;echo '</font></center></td>
';
if ($showactions) {
;echo '              <td valign="middle" bgcolor="';echo $basecolour;;echo '">
<center>
<a href="';echo $_SERVER[SCRIPT_NAME] ;echo '?action=ri&id=';echo $recid;;echo '" style="border-style:none;"><img src="../images/reinstate.png" border="0" alt="Reinstate" title="Reinstate"></a>
';if ($reinstate_date == 'Permanent Ban') {;echo '                    
<img src="../images/permban_d.png" border="0" alt="Permanently Ban (n/a)" title="Permanently Ban (n/a)">
';}else {;echo '                  <a href="';echo $_SERVER[SCRIPT_NAME] ;echo '?action=pb&id=';echo $recid;;echo '" style="border-style:none;"><img src="../images/permban.png" border="0" alt="Permanently Ban" title="Permanently Ban"></a>
';};echo '                </center>
</td>
';
}
;echo '            </tr>
';
}
Function DisplayMemberForAction($actiontitle,$actionbuttontitle,$actionid,$contrastcolour,$basecolour,$fonttype,$fontcolour) {
$query = 'SELECT * FROM member_deletes WHERE id='.$actionid.';';
$result = mysql_query ($query) or die ('Query failed');
;echo '        <font size="2" face="';echo $fonttype ;echo '" color="';echo $fontcolour ;echo '"><p><center>
<center>
<p>
<b>';echo $actiontitle;;echo '</b>
</p>
</center>
';
CreateListHeader(false,$contrastcolour,$fonttype,$fontcolour);
$mem_del_rec = mysql_fetch_array($result);
;echo ' <tbody> ';
CreateListRow($mem_del_rec,false,$basecolour,$fonttype,$fontcolour);
;echo '					</tbody>
</table>
<br><br>
<center>
<form action="';echo $_SERVER[SCRIPT_NAME] ;echo '" name="actionform">
<input type="hidden" name="id" value="';echo $actionid;;echo '" />
<input type="submit" name="action" value="';echo $actionbuttontitle;;echo '">&nbsp;
<input type="submit" value="Cancel">
</form>
</center>
<br><br>
';
}
function view_sort($sort) {
if($sort == 'name')
{
$orderby='name ASC';
}
elseif($sort == 'userid')
{
$orderby='userid ASC';
}
elseif($sort == 'memtype')
{
$orderby='memtype ASC';
}
elseif($sort == 'email')
{
$orderby='contact_email ASC';
}
elseif($sort == 'ip')
{
$orderby='ip ASC';
}
elseif($sort == 'verfied')
{
$orderby='verified ASC';
}
elseif($sort == 'points')
{
$orderby='points DESC';
}
elseif($sort == 'commission')
{
$orderby='commission DESC';
}
elseif($sort == 'joindate')
{
$orderby='joindate DESC';
}
elseif($sort == 'referid')
{
$orderby='referid DESC';
}
else
{
$orderby='joindate DESC';
}
return $orderby;
}
function admin_cutompages () {
extract($GLOBALS);
echo "<font size=2 face='$fonttype' color='$fontcolour'>";
if($_POST['action'] == 'editcustompage') {
$id = $_POST['id'];
$name = $_POST['name'];
$htmlcode = $_POST['htmlcode'];
$memtype = $_POST['memtype'];
$query = "update custompages set name='$name', htmlcode='$htmlcode', memtype='$memtype' where id=".$id;
$result = mysql_query ($query) or die ('failed');
echo '<p><center>'.$name.' has been edited.</p></center></td></tr></table>';
;echo '<head>

<META HTTP-EQUIV="Refresh"

CONTENT="0; URL=custompages.php">

</head>
';
}
elseif($_POST['action'] == 'editpage') {
$id = $_POST['id'];
$query = "select * from custompages WHERE id='$id'";
$result = mysql_query ($query)
or die ('Query failed');
;echo '<table width=70% border=0 cellpadding=2 cellspacing=2><tr><td>

';
while ($line = mysql_fetch_array($result)) {
$id = $line['id'];
$name = $line['name'];
$htmlcode = $line['htmlcode'];
$memtype = $line['memtype'];
;echo ' 
<form method="POST">
<input type="hidden" name="action" value="editcustompage">
<input type="hidden" name="id" value="';echo $id;;echo '">
<table border=0 cellpadding=3 cellspacing=0>
<tr><td align=center><b>Edit Custom Page</b></td></tr>
<tr><td align=center>Name:<br><input type="text" name="name" value="';echo $name;;echo '"></td></tr>
<tr><td align=center>Content:<br><textarea name="htmlcode" rows=25 cols=75>';echo $htmlcode;;echo '</textarea><br></td></tr>
<tr><td align=center>Allowed To View: <input type="radio" name="memtype" value="1"';if($memtype == '1') echo ' CHECKED';;echo '> Pro <input type="radio" name="memtype" value="2"';if($memtype == '2') echo ' CHECKED';;echo '> JV Member <input type="radio" name="memtype" value="3"';if($memtype == '3') echo ' CHECKED';;echo '> SUPER JV <input type="radio" name="memtype" value="0"';if($memtype == 0) echo ' CHECKED';;echo '> All</td></tr>
<tr><td align=center><input type="submit" value="Edit Custom Page"></td></tr></table>
</td></tr></table>
</form>




';
}
echo '</td></tr></table></center>';
}
elseif($_POST['action'] == 'addpage') {
$name = $_POST['name'];
$htmlcode = $_POST['htmlcode'];
$memtype = $_POST['memtype'];
$query = "insert into custompages (id,name,htmlcode,memtype) values('','$name','$htmlcode','$memtype')";
$result = mysql_query ($query) or die ('failed');
echo '<p><center>'.$name.' has been added to the custom pages.</p></center></td></tr></table>';
;echo '<head>

<META HTTP-EQUIV="Refresh"

CONTENT="0; URL=custompages.php">

</head>
';
}
elseif($_POST['action'] == 'deletepage') {
$id = $_POST['id'];
mysql_query("DELETE FROM custompages WHERE id='$id'");
echo '<p><center>The page has been deleted.</p></center></td></tr></table>';
;echo '<head>

<META HTTP-EQUIV="Refresh"

CONTENT="0; URL=custompages.php">

</head>
';
}
else {
$query = 'select * from custompages';
$result = mysql_query ($query)
or die ('Query failed');
;echo ' <H2>Current Custom Pages</H2>
<table width=70% border=0 cellpadding=2 cellspacing=2>

';
while ($line = mysql_fetch_array($result)) {
$id = $line['id'];
$name = $line['name'];
$htmlcode = $line['htmlcode'];
$memtype = $line['memtype'];
if($memtype=='1') {
$yourmem = 'PRO';
}elseif($memtype=='2') {
$yourmem = 'JV Member';
}elseif($memtype=='3') {
$yourmem = 'SUPER JV';
}elseif($memtype=='0') {
$yourmem = 'ALL';
}
;echo '<tr>
<td bgcolor="';echo $basecolour;;echo '"><center><font size=2 face="';echo $fonttype;;echo '" color="';echo $fontcolour;;echo '">Name: ';echo $name;;echo '<br>Content:<br><div style="width: 600px; height: 200px; padding: 4px; overflow:auto; border-style: solid; border-size: 1px; border-color: #000000; background: #ffffff;">';echo $htmlcode;;echo '</div><br>Allowed To View: ';echo $yourmem;;echo '<br>

The url to this page is <a href="/members/page.php?id=';echo $id;;echo '" target=NEW>';echo $domain;;echo '/members/page.php?id=';echo $id;;echo '</a>
<form method="POST">
<input type="hidden" name="action" value="deletepage">
<input type="hidden" name="id" value="';echo $id;;echo '">
<input type="submit" value="Delete">
</form>
<form method="POST"><input type="hidden" name="action" value="editpage">
<input type="hidden" name="id" value="';echo $id;;echo '">
<input type="submit" value="Edit">
</form>
</center></td>
</tr>
<tr><td><HR ALIGN= "center" size= 5 WIDTH= 100% COLOR= "#000000" NO SHADE>	</td></tr>
';
}
echo '</table></center>';
;echo '




<p>
<form method="POST">
<input type="hidden" name="action" value="addpage">
<table border=0 align=center><tr><td>
<table border=0 align=center cellpadding=3 cellspacing=0>
<tr><td align=center><b>Add New Custom Page</b></td></tr>
<tr><td align=center>Name:<br><input type="text" name="name"></td></tr>
<tr><td align=center>Content:<br><textarea name="htmlcode" rows=25 cols=75></textarea><br></td></tr>
<tr><td align=center>Allowed To View:<input type="radio" name="memtype" value="1"> PRO <input type="radio" name="memtype" value="2"> JV member <input type="radio" name="memtype" value="3"> SUPER JV <input type="radio" name="memtype" value="0" CHECKED> All</td></tr>
<tr><td align=center>&nbsp;<input type="submit" value="Add New Page"></td></tr></table>
</td></tr></table>

</form>
</p>



';
echo '</td></tr></table>';

}
};
?>