<?php session_start();  //Developed by ITechScripts
?>
<style type="text/css">
<!--
.style1 {
	color: #666666;
	font-weight: bold;
}
.style3 {color: #666666; font-size: 11px; font-family:Arial, Helvetica, sans-serif}
-->
</style><?php
require 'include/configurations.php'; // ITECHBIDS Configuration File
$mode=$_GET['mode'];
if($mode=="")
{
$mode='actv';
}
$userid=$_GET['id'];
$type=$_GET['type'];
if(!$type)
 $type='gen';
if($mode=='vrfy')
{
$vres=mysql_query("update member_details set verified='yes'  where user_id=$userid");
$message="Verified sucessfully";
}
if($mode=='suspend')
{
$sresult=mysql_query("update member_details set status='suspended' where user_id=$userid");
$message="Suspended sucessfully";

}
else if($mode=='delete')
{
$dresult=mysql_query("delete from member_details where user_id=$userid");
$message="Deleted suessfully";
}

else if($mode=='dupi') {
$sresult=mysql_query("update member_details set status='Active' where user_id=$userid");
$message="Activated sucessfully";
}
else if($mode=='appr') {
$sresult=mysql_query("update member_details set approved='yes' where user_id=$userid");
$message="Approved sucessfully";
}
else if($mode=='unpaid')
 {
$sresult=mysql_query("update member_details set member_account='$user_row[original_account]' , paid='no' where user_id=$userid");
$message="Updated Sucessfully";
$mode='';
$userid=$_GET[id];
$user_res=mysql_query($user_sql);
$user_row=mysql_fetch_array($user_res);
}
else if($mode=='paid')
{
$sresult=mysql_query("update member_details set member_account='$user_row[original_account]' , paid='yes' where user_id=$userid");
$message="Updated Sucessfully";
$mode='';

}
else if($mode=='trusted')
{
$userid=$_GET[id];
$sresult=mysql_query("update member_details set trusted='inactive' where user_id=$userid");
$message="Updated sucessfully";
}


else if($mode=='actv')
{
$asql="update member_details set status='Active' where user_id=$userid";
$aresult=mysql_query($asql);
$message="Activated sucessfully";
}
if(isset($_POST['delete']))
{
$coid=$_POST['chkSub'];
for($i=0;$i<count($coid);$i++) {
$cnid=$coid[$i];
$dsql="delete from member_details where user_id='$cnid'";
$dresult=mysql_query($dsql);
$message="Deletes Sucessfully";
}
}
$cansave=$_POST['cansave'];
//exit();
if($cansave==1)
{
echo '<meta http-equiv="refresh" content="0; url=addnew.php">';
exit();
 }
?>
><?php
require 'include/header.php';
?>
<div align="right"><a href="adduser.php" id="link1" style="text-decoration:none"> 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></div>
<br>
<table width="80%"  border="0" cellpadding="5" cellspacing="1" class="ft" align="center">
<form name="frmsearch" method="post">
 <tr class="ct" height="25"><td colspan="4">Search</td></tr>
 <tr ><td>Username</td><td><input type="text" class="bluetext"name="txtSname" >
 </td><td>member_email</td>
 <td><input type="text" class="bluetext"name="txtSmail" ></td></tr>
 <tr ><td colspan="4"><table align="center" width="100%">
 <tr><td>date_of_join After</td><td>
 <select name="cboAday" class="cbo">
 <option value="">Day</option>
 <?php
 for($i=1;$i<=31;$i++)
 {
 ?>
 <option value="<?=$i; ?>"><?=$i; ?></option>
 <?php
 }
 ?>
 </select></td>
 <td>
 <select name="cboAmonth" class="cbo">
				<option value="">Month</option>
				<?
					$montharr="dumm,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec";
					$month=explode(',',$montharr);
					for($i=1;$i<=12;$i++) { 
					   echo "<option value=$i>$month[$i]</option>"; 
					}
				?>
			  </select>
 </td>
 <td> <select name="cboAyear" class="cbo">
 <option value="">Year</option>
 <?php
 for($i=2004;$i<=2020;$i++)
 {
 ?>
 <option value="<?=$i; ?>"><?=$i; ?></option>
 <?php
 }
 ?>
 </select></td>
 <td>date_of_join Before</td>
<td>
 <select name="cboBday" class="cbo">
 <option value="">Day</option>
 <?php
 for($i=1;$i<=31;$i++)
 {
 ?>
 <option value="<?=$i; ?>"><?=$i; ?></option>
 <?php
 }
 ?>
 </select></td>
 <td>
 <select name="cboBmonth" class="cbo">
				<option value="">Month</option>
				<?
					$montharr="dumm,Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec";
					$month=explode(',',$montharr);
					for($i=1;$i<=12;$i++) { 
					   echo "<option value=$i>$month[$i]</option>"; 
					}
				?>
			  </select>
 </td>
 <td> <select name="cboByear" class="cbo">
 <option value="">Year</option>
 <?php
 for($i=2004;$i<=2020;$i++)
 {
 ?>
 <option value="<?=$i; ?>"><?=$i; ?></option>
 <?php
 }
 ?>
 </select></td></table> </td></tr>
 <tr ><td colspan="4" align="center">
 <input type="submit" class="button"   name="search" value="Search" ></td></tr>
</form></table>
<br>
<table align="center" width="90%"><tr>
<td align="center"><a id="tablink" href="user.php?mode=actv">Active Users</a></td>
<td align="center"><a id="tablink" href="user.php?mode=appr">Pending Approval</a></td>
<td align="center"><a id="tablink" href="user.php?mode=suspend">Suspended Users</a></td>
<td align="center"><a id="tablink" href="user.php?mode=new">New Users</a></td>
<td align="center"><a id="tablink" href="user.php?mode=unver">Unverified Users</a></td>
</tr></table>
<br>
<?php 
if($mode!='view')
{
	  $date=date('Y-m-d');
	  if(isset($_POST['search']))
	  {
$name=$_POST['txtSname'];
$member_email=$_POST['txtSmail'];
$array1=array($_POST['cboAyear'],$_POST['cboAmonth'],$_POST['cboAday']);
$array2=array($_POST['cboByear'],$_POST['cboBmonth'],$_POST['cboBday']);
$adate=implode('-',$array1);
$bdate=implode('-',$array2);
$sql="select * from member_details where";
if($name!='')
$sql.=" user_name='$name' and ";
if($member_email!='')
$sql.=" email='$member_email' and ";
if($adate!='' && $adate!='--')
$sql.="  date_of_registration >='$adate' and ";
if($bdate!='' && $bdate!='--' )
$sql.="  date_of_registration <='$bdate' and ";
$sql=substr($sql,0,-4);
}
else
{

      if($mode=='')
	    $sql="select * from member_details ";
	  if($mode=='actv')
	  $sql="select * from member_details where status='active' and verified='yes' and user_type='original'";
	  else if($mode=='suspend')
	  $sql="select * from member_details where status='suspended' and verified='yes' and user_type='original'";
	  else if($mode=='new')
	  {
	  $date1=date('Y-m-d');
	  $sql="select * from member_details where date_of_registration='$date1' and user_type='original'";
	  }
	  else if($mode=='unver')
	  $sql="select * from member_details where verified='no' and user_type='original'";
	  else if($mode=='appr')
	  $sql="select * from member_details where approved='no' and user_type='original'";
	  else if($mode=='dup')
	  $sql="select * from member_details where status='duplicate' and verified='yes' and user_type='original'";
	  else if($mode=='paid')
	  $sql="select * from member_details where paid='Yes' and ( original_account=2 or original_account=3 )";
	  else if($mode=='unpaid')
	  $sql="select * from member_details where paid='No' and ( original_account=2 or original_account=3 )";
	  else if($mode=='trusted')
	  $sql="select * from member_details where trusted='trusted'";
	  
	  else if($mode=='jointoday')
	  {
	  $date1=date('Y-m-d');
	  $sql="select * from member_details where date_of_registration='$date1'";
	  }
	  else 
	  {
	  $sql="select * from member_details";
	  //$mode='actv';
	  }
}
	  $res=mysql_query($sql);
	  if(mysql_num_rows($res)>0)
	  {
?>
<table width="90%"  border="0" cellpadding="5" cellspacing="1" class="ft" align="center">
<form name="frm1" method="post" action="addnew.php">
      <tr class="ct">

        <td width="17%"><div align="center"><span height="25">User Name </span></div></td>
        <td width="19%"><div align="center"><span height="25">E-mail</span></div></td>
        <td width="13%" class="ct" height="25">Country</td>
        <td width="16%"><div align="center" height="25">Date Of Join</div></td>
        <td width="16%"><div align="center" height="25">Bid Left</div></td>
        <td width="6%"><div align="center"><span height="25">Edit</span></div></td>
        <td width="10%"><div align="center"><span height="25">Status</span></div></td>
        <td width="9%"><div align="center"><span height="25">Delete</span></div></td>
        <td width="2%"><div align="right"></div></td>
      </tr>
      <?php
	$total_records=mysql_num_rows($res);
	$curpage=$_GET['curpage'];
	if(strlen($_GET['curpage']) == 0) $curpage=1;
	$start=($curpage-1) * 10;
	$end=10;
	if($curpage==''|| $curpage==1)
	$i=1;
	else $i=$_GET['sno']+1;
	$sql.=" limit $start,$end";
	$res=mysql_query($sql);
 ?>
        <tr> 
          <td align="right" colspan="10"> 
            <?php
	if($curpage!=1) {
?>
            <a href="user.php?mode=<?=$mode; ?>&curpage=<?=($curpage-1);?>" id="link2">Prev</a> 
            | 
            <?php
}
?>
            <?php
if($total_records > ($start + $end)) {
?>
            <a href="user.php?mode=<?=$mode; ?>&curpage=<?=($curpage+1);?>" id="link2">Next</a> 
            <?php
}
?>
          </td>
        </tr>
<?php
while($row=mysql_fetch_array($res))
{
?>
      <tr >

        <td>
		<a href="useritechds.php?type=gen&id=<?=$row['user_id']; ?>" style="text-decoration:none" id="link1">
		<?=$row['user_name']; ?></a></td>
        <td>
          <?=$row['email']; ?>
        </td>
        <td>
        <?php $cntry=$row['country'];
		$cres=mysql_query("select * from site_countries where country_id=$cntry");
		$crow=mysql_fetch_array($cres);
		echo $crow['country'];
		?></td>
        <td><?=$row['date_of_registration']; ?></td>
        <td><?=$row['bid_num']; ?></td>
        <td><div align="center" class="style3">
		 <a href="adduser.php?id=<?=$row['user_id']; ?>&mode=edit" style="text-decoration:none" id="link1">Edit</a></div></td>
<td><div align="center" class="style3"><?php if($mode=='actv') { ?>
		<a href="user.php?id=<?=$row['user_id']; ?>&mode=suspend" style="text-decoration:none"  id="link1">Suspend</a>
		<?php } else if($mode=='suspend') { ?><a href="user.php?id=<?=$row['user_id']; ?>&mode=actv" style="text-decoration:none" id="link1">Activate</a>
		<?php } 
		else if($mode=='dup') {
		?>
		<a href="user.php?id=<?=$row['user_id']; ?>&mode=dup" style="text-decoration:none"  id="link1">Activate</a>
		<?
		}
		if($mode=='unver') { ?>
		<a href="user.php?id=<?=$row['user_id']; ?>&mode=vrfy" style="text-decoration:none"  id="link1">Verify</a>
		<?php } else if($mode=='new' || $mode=='') 
		{
		?>
		<a href="user.php?id=<?=$row['user_id']; ?>&mode=active" style="text-decoration:none" id="link1">Activate</a>
		<?php
		} 
		else if($mode=='paid') 
		{
		?>
		<a href="user.php?id=<?=$row['user_id']; ?>&mode=unpaid" style="text-decoration:none" id="link1">Unpaid</a>
		<?php
		} 
                else if($mode=='appr') 
		{
		?>
		<a href="user.php?id=<?=$row['user_id']; ?>&mode=appr" style="text-decoration:none" id="link1">Approve</a>
		<?php
		} 
		else if($mode=='unpaid') 
		{
		?>
		<a href="user.php?id=<?=$row['user_id']; ?>&mode=paid" style="text-decoration:none" id="link1">Paid</a>
		<?php
		} 
		else if($mode=='trusted') 
		{
		?>
		<a href="user.php?id=<?=$row['user_id']; ?>&mode=trusted" style="text-decoration:none" id="link1">Untrusted</a>
		<?php
		} 
		?>
				</div></td> 
		<td><div align="center" class="style3"><a href="user.php?id=<?=$row['user_id']; ?>&mode=delete"  id="link1" style="text-decoration:none" onClick="javascript:return condelete();">Delete</a></div></td>
      </tr>
      <?php
	  }
?>
  <tr >
  <td colspan="10" align="center" >
  <input type="hidden" name="cansave" value="0">
  <input type="hidden" name="canDel" value="0">
  <input type="submit" class="button"   value="Add New" name="addnew"   onClick="addnew();">
</td>
  </tr>
  </form></table><?php
}
else
{
?>
<div align="center" style="font-family: Arial Helvetica; font-weight:bold">No Users Found</div><?php 
}
}
else if($mode=='view')
{
	if($type=='gen') 
		$vres=mysql_query("select * from member_details where user_id=$userid");
	else if($type=='acc')	
		$vres=mysql_query("select * from deposit where member_id=$userid");
	else if($type=='dep')	
		$vres=mysql_query("select * from deposit where member_id=$userid");
	else if($type=='wit')	
		$vres=mysql_query("select * from history where user_id=$userid and (type='withdrawal' or type='withdraw_pending')");
	else if($type=='ref')	
		$vres=mysql_query("select * from deposit where member_id=$userid");
?>
          <table width="80%"  border="0" cellpadding="5" cellspacing="1" class="ft" align="center">
		  <tr><td colspan="2">
		  <table border="0" align="center" cellpadding="5" cellspacing="2" width="100%">
		  <tr>
		  <td><a href="user.php?mode=view&type=gen&id=<?=$userid?>">Personal Details</a></td>
		  <td><a href="user.php?mode=view&type=acc&id=<?=$userid?>">Account Details</a></td>
		  <td><a href="user.php?mode=view&type=dep&id=<?=$userid?>">Deposit Details</a></td>
		  <td><a href="user.php?mode=view&type=wit&id=<?=$userid?>">Withdraw Details</a></td>
		  <td><a href="user.php?mode=view&type=ref&id=<?=$userid?>">Referral Details</a></td>
		  </tr>
		  </table>
		  </td></tr>
 			<?	

					while($vrow=mysql_fetch_array($vres)) {
					if($type=='gen') {
			?>
            <tr> 
              <td width="22%" class="ct" height="25"  ><strong>User Name</strong></td>
              <td width="78%" > 
                <?=$vrow['username']; ?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" ><strong>member_email</strong></td>
              <td > 
                <?=$vrow['member_email']; ?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" ><strong>City</strong></td>
              <td > 
                <?=$vrow['city']; ?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" ><strong>State</strong></td>
              <td > 
                <?=$vrow['state'];?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" ><strong>Country</strong></td>
              <td > 
                <?php $cntry=$vrow['country'];
		 $cres=mysql_query("select * from site_countries where country_id=$cntry");
		$crow=mysql_fetch_array($cres);
		echo $crow['country'];
		?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" ><strong>Member Since</strong></td>
              <td > 
                <?=$vrow['date_of_join']; ?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" ><strong>Status</strong></td>
              <td > 
                <?php 
 if($vrow['status']=='active')
 $status='Active';
 else if($vrow['status']=='new')
 $status='New User';
 else if($vrow['status']=='suspended')
 $status='Suspended';
 else if($vrow['status']=='duplicate')
 $status='Duplicate IP';
 if($vrow['verified']=='yes')
 $ver='Verified';
 else
 $ver='Unverified';
  echo $status,' , '.$ver;
  ?>
              </td>
            </tr><?php
	}
	
   else if($type=='dep') {
   $userid=$vrow['member_id'];
   $user_res=mysql_query("select * from members where member_id=$userid");	
   $user_row=mysql_fetch_array($user_res);
   $username=$user_row['username'];
   
   $plansql=mysql_query("select * from plan where plan_id=".$vrow['plan_id']);
   $planrow=mysql_fetch_array($plansql);
   $plan_name=$planrow['plan_type'];
   
   $paymentsql=mysql_query("select * from payment_process where payment_id=".$vrow['payment_thro']);
   $paymentrow=mysql_fetch_array($paymentsql);
   $paymentname=$paymentrow['payment_name'];
?>
            <tr> 
              <td width="22%" class="ct" height="25"  ><strong>User Name</strong></td>
              <td width="78%" > 
                <?=$username; ?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" ><strong>Plan</strong></td>
              <td > 
                <?=$plan_name; ?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" >Amount</td>
              <td > 
              $ <?=$vrow['amount']; ?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" ><strong>Payment Through</strong></td>
              <td > 
                <?=$paymentname;?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" >Interest Earned </td>
              <td > 
               $ <?=number_format($vrow['intrest_earned'],2);?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" >Interest Earned Date </td>
              <td > 
                 <?=$vrow['intrest_earned_date']; ?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" ><strong>Status</strong></td>
              <td > 
                <?=$vrow['status'];?>
              </td>
            </tr><?php
	}
	else if($type=='wit')
	 {
   $userid=$vrow['user_id'];
   $user_res=mysql_query("select * from members where member_id=$userid");	
   $user_row=mysql_fetch_array($user_res);
   $username=$user_row['username'];
   
   $plansql=mysql_query("select * from plan where plan_id=".$vrow['plan_id']);
   $planrow=mysql_fetch_array($plansql);
   $plan_name=$planrow['plan_type'];
   
   $paymentsql=mysql_query("select * from payment_process where payment_id=".$vrow['payment_thro']);
   $paymentrow=mysql_fetch_array($paymentsql);
   $paymentname=$paymentrow['payment_name'];
?>
            <tr> 
              <td width="22%" class="ct" height="25"  ><strong>User Name</strong></td>
              <td width="78%" > 
                <?=$username; ?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" ><strong>Plan</strong></td>
              <td > 
                <?=$plan_name; ?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" >Amount</td>
              <td > 
              $ <?=$vrow['amount']; ?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" ><strong>Payment Through</strong></td>
              <td > 
                <?=$paymentname;?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" >Interest Earned </td>
              <td > 
               $ <?=number_format($vrow['intrest_earned'],2);?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" >Interest Earned Date </td>
              <td > 
                 <?=$vrow['intrest_earned_date']; ?>
              </td>
            </tr>
            <tr> 
              <td class="ct" height="25" ><strong>Status</strong></td>
              <td > 
                <?=$vrow['status'];?>
              </td>
            </tr>

<?
	}
	}
?>	
          </table><?php
}
//------------------------Suspend--------------------------------------

?>
<script language="JavaScript">
function chkall() {
	len=document.frm1.chkSub.length;
	if(len > 1) {
	for(i=0;i<len;i++) {
		if(document.frm1.chkMain.checked==true) {
			document.frm1.chkSub[i].checked=true;
		}
		else {
			document.frm1.chkSub[i].checked=false;
		}
	}
	}
	else {
		if(document.frm1.chkMain.checked==true) {
			document.frm1.chkSub.checked=true;
		}
		else {
			document.frm1.chkSub.checked=false;
		}
	
	}
	}

function condelete()
{
var confrm;
confrm=window.confirm("Are You sure you want to delete this User");
document.frm1.canDel.value=1;
return confrm;
}
function addnew()
{
document.frm1.cansave.value=1;
document.frm1.submit();
}

</script>
<?
	require 'include/footer.php';
?>