<?
ob_start();
session_start();
if($_SESSION['uname']=='' || $_SESSION['pwd']=='')
		{
			header("location:login.php");
		}
 include("../include/db.inc.php");
 include("../include/pager.php"); 
 include("../include/bit_functions.inc.php");
   $db1=new db;
   $db1->open();
    mysql_query("SET NAMES 'utf8'");
   
   
   if(isset($_GET['blocked']))
{
$blocked=$_GET['blocked'];

if($blocked==1)
$blocked=0;
else
$blocked=1;
$id=$_GET['id'];
$sql="update user set blocked='$blocked' where id='$id'";
mysql_query($sql);
header("location:user_list.php");
exit();
}
   	if($_GET['del']){
		
		   $del_query=mysql_query("delete from user where id=".$_GET['del']);
			
		}
		
		
	

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Money Auctions | Admin Controls</title>
<link href="index.css" rel="stylesheet" type="text/css" />

<script language="JavaScript" src="../js/common.js"></script>
<script language="JavaScript">
function veiwmem(id){
			window.open('view_user.php?id='+id,'','width=800,height=800,top=5,left=180');		
	}	
	</script>
<style type="text/css">
<!--
.style1 {color: #093A9C}
.style2 {color: #FE6905}
-->
</style>
</head>
<body>
<div class="admin_wrapper">
<div class="logo_show"><? include("minorlogout.php");?></div>
<div style="float:left; width:200px">
<div class="topg_links_show"><? include("left.php");	?></div>
<div class="top_links_show"><? include("belowleft1.php");	?></div></div>
<div style="float:left; width:800px">
<div class="maximum"><br />
<br />
<TABLE WIDTH="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0 align="center">
        <TR> 
          <TD> <img border='0' src="border_img/circle_01.gif" WIDTH=36 HEIGHT=35 ALT=""></TD>
          <TD width="679" height="34" valign="top" > <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
               
                <td width="100%" background="border_img/circle_02.gif">&nbsp;</td>
              </tr>
            </table></TD>
          <TD> <img border='0' src="border_img/circle_03.gif" WIDTH=35 HEIGHT=35 ALT=""></TD>
        </TR>
        <TR> 
          <TD width="36" background="border_img/circle_04.gif">&nbsp; </TD>
          <TD align="left" valign="top"> 
	<table width="83%" border="0" cellpadding="1" cellspacing="0">
	<form name="search_form" action="user_list.php" method="get">
		<tr>
		<td width="13%">User Name:</td>
		<td width="31%"><input type="text" name="uname" /></td>
		<td width="17%">&nbsp;</td>
		<td width="10%"> Order By</td>
		<td width="29%"><select name="orderby" style="width:150px">
		<option value="0">--Select Order By--</option>
		<option value="1">Random</option>
		<option value="2">User Name</option>
		<option value="3">Email</option>
		<option value="4">No. Remaining Bids</option>
		
		</select></td>
		</tr>
		<tr>
		<td>Email:</td>
		<td><input type="text" name="email" /></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td></td>
		</tr>
		<tr>
		<td>Gender:</td>
		<td><select name="gender" style="width:150px">
		<option value="">--Select Gender--</option>
		<option value="male">Male</option>
		<option value="female">Female</option>
		</select></td>
		<td>&nbsp;</td>
		<td></td>
		</tr>
		<td>Country:</td>
		<td><select name="country" style="width:150px">
		<option value="">--Select Country--</option>
		 <?    $country=mysql_query("select * from country order by state ");
					while($row_c=mysql_fetch_array($country))
					{
							?>
							<option value="<?=$row_c['state'];?>"><?=$row_c['state'];?></option>
							<? }?>		</select></td>
		<td>&nbsp;</td>
		<td></td>
		</tr>
		<tr>
		<td colspan="5"><input type="submit" name="search" value="SEARCH" /></td>
		
		</tr>
		</form>
	</table>

	  </TD>
          <TD width="35" background="border_img/circle_06.gif">&nbsp; </TD>
        </TR>
        <TR> 
          <TD> <img border='0' src="border_img/circle_07.gif" WIDTH=36 HEIGHT=34 ALT=""></TD>
          <TD height="34" background="border_img/circle_08.gif">&nbsp; </TD>
          <TD> <img border='0' src="border_img/circle_09.gif" WIDTH=35 HEIGHT=34 ALT=""></TD>
        </TR>
      </TABLE>


<? if(isset($_GET['inactive'])){?>
<table  width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
  <tr> 
    <td width="15" valign="top">&nbsp;</td>
          <td valign="top"><br> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
        <tr> 
          <td width="33" valign="top"><img src="img/03.gif" width="33" height="23"></td>
                  
                <td width="339" background="img/bg01.gif"><strong>TOTAL INACTIVE USER LIST </strong></td>
				<td width="163" background="img/bg01.gif"><a href="user_list.php">Show User List</a></td>
				<td width="165" background="img/bg01.gif"><a href="user_list.php?online">Online User</a></td>
          <td width="35"><img src="img/04.gif" width="35" height="23"></td>
        </tr>
      </table>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
        <tr> 
          <td width="22" height="185" valign="top" background="img/tbl-left04.gif">
          <img border='0' src="img/tbl-left04.gif" width="22" height="13"></td>
          <td valign="top" align="center"><br>		  		  		             
	
                   <form action="" method="post" enctype="multipart/form-data" name="form1">
                    <table width="100%" border="1" cellspacing="1" cellpadding="1" style="border-collapse:collapse;border-color:#FED267" >
                      <tr bgcolor="#FED267"> 
					   <td width="7%"  align="center"><strong><font color="#FFFFFF">S.No.</font></strong></td>
                       
                        <td width="12%" >&nbsp;&nbsp;<strong><font color="#FFFFFF">Username</font></strong></td>
                        <td width="16%" ><strong><font color="#FFFFFF">Email</font></strong></td>
						 <td width="16%" ><strong><font color="#FFFFFF">No. Of Remaining Bids</font></strong></td>
                        <td width="20%" height="21" align="center"><font color="#FFFFFF"><strong>Status</strong>&nbsp;&nbsp;  (select checkbox user blocked)</font></td>
						<td width="13%" height="21" align="center"><strong><font color="#FFFFFF">Edit</font></strong></td>
                        <td width="13%" height="21" align="center"><strong><font color="#FFFFFF">Delete</font></strong></td>
                      </tr>
					  
					  <?
					  
					  $limit=10;
					  $i=getStart($limit);	
					  $sel_query=mysql_query(dopaging("select id,uname,email,no_bids,blocked from user where confirm='0'",$limit)) or die(mysql_error());
					  
                      while($myrow=mysql_fetch_array($sel_query)){  
					  $i++;
					  ?>
                      <tr onMouseOver="this.style.backgroundColor='#FFECBF'" onMouseOut="this.style.backgroundColor='#ffffff'"> 
					  <td height="28"  align="center"><?=$i;?></td>
                    
                              
                        <td >&nbsp;&nbsp;
						<a class="link5" style="font-size:12px;"  href="javascript:veiwmem(<?=$myrow['id']?>)" title="Click To View User Information" ><?=$myrow['uname']?></a></td>
                       
                        <td style="padding-left:5px;"><?=$myrow['email'];?></td>
						
                        <td style="padding-left:5px;"><?=$myrow['no_bids'];?></td>
                        <td >&nbsp;&nbsp;&nbsp;&nbsp;
						<?
						if($myrow['blocked']=='1')
						{
						?>
		<a href="user_list.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>">
		<input  name="chk[]" type="checkbox" checked 
        onClick="window.location='user_list.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>'" >
        </a>
		                 <?
                            }
						else
						
						   {
						   ?>
		<a href="user_list.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>">
        <input  name="chk[]" type="checkbox" 
        onClick="window.location='user_list.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>'" >
		</a>
                             <?
						   }	
						
						?>
						</td>
                      
                      <td>Edit</td>
						  
						  
          <td><a href="user_list.php?del=<?=$myrow['id']?>"  onClick="return confirm('Are you sure to delete this User ?');"><img src="../images/category/imgdelete.gif" border="0"></a>
                        </td>
                      </tr>
                      <? 
									} if(rightpaging())?>
				<tr><td height="22" colspan=7 align=center><br>
				  <?=rightpaging()?></td></tr>
                    </table>
                 
      </form>
          <td width="19" valign="top" background="img/tbl-right04.gif"><img src="img/tbl-right04.gif" width="19" height="9"></td>
        </tr> 
      </table>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
        <tr> 
          <td width="33"><img src="img/tbl-bot01.gif" width="33" height="12"></td>
          <td width="709" align="right" background="img/tbl-bg.gif"></td>
          <td width="33"><img src="img/tbl-right05.gif" width="35" height="12"></td>
        </tr>
      </table>
      </td>
  </tr>
  
</table>
<? }else if(isset($_GET['online'])){?>
<table  width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
  <tr> 
    <td width="15" valign="top">&nbsp;</td>
          <td valign="top"><br> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
        <tr> 
          <td width="33" valign="top"><img src="img/03.gif" width="33" height="23"></td>
                  
                <td background="img/bg01.gif"><strong>ONLINE USER LIST </strong></td>
				<td background="img/bg01.gif"><a href="user_list.php">Show User List</a></td>
				<td background="img/bg01.gif"><a href="user_list.php?inactive">Total Inactive User</a></td>
          <td width="35"><img src="img/04.gif" width="35" height="23"></td>
        </tr>
      </table>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
        <tr> 
          <td width="22" height="185" valign="top" background="img/tbl-left04.gif">
          <img border='0' src="img/tbl-left04.gif" width="22" height="13"></td>
          <td valign="top" align="center"><br>		  		  		             
	
                   <form action="" method="post" enctype="multipart/form-data" name="form1"> 
                    <table width="100%" border="1" cellspacing="1" cellpadding="1" style="border-collapse:collapse;border-color:#FED267">
                      <tr bgcolor="#FED267"> 
					   <td width="4%"  align="center"><strong><font color="#FFFFFF">S.No.</font></strong></td>
                       
                        <td width="11%" >&nbsp;&nbsp;<strong><font color="#FFFFFF">Username</font></strong></td>
                        <td width="12%" ><strong><font color="#FFFFFF">Email</font></strong></td>
						
                        <td width="12%" ><strong><font color="#FFFFFF">No. Of Remaining Bids</font></strong></td>
                        <td width="16%" height="21" align="center"><font color="#FFFFFF"><strong>Status</strong>&nbsp;&nbsp;  (select checkbox user blocked)</font></td>
                        <td width="9%" height="21" align="center"><strong><font color="#FFFFFF">Delete</font></strong></td>
                      </tr>
					  
					  <?
					  
					  $limit=10;
					  $i=getStart($limit);	
					  $sel_query=mysql_query(dopaging("select id,uname,email,no_bids,blocked from user where confirm='1' and 
					  usetime > (select date_sub(now(),interval 10 minute)) and user_online='1'",$limit)) or die(mysql_error());
					  
                      while($myrow=mysql_fetch_array($sel_query)){  
					  $i++;
					  ?>
                      <tr onMouseOver="this.style.backgroundColor='#FFECBF'" onMouseOut="this.style.backgroundColor='#ffffff'"> 
					  <td  align="center"><?=$i;?></td>
                     
                              
                        <td >&nbsp;&nbsp;
						<a class="link5" style="font-size:12px;"  href="javascript:veiwmem(<?=$myrow['id']?>)" title="Click To View User Information" ><?=$myrow['uname']?></a></td>
                       
                        <td style="padding-left:5px;"><?=$myrow['email'];?></td>
						
                        <td style="padding-left:5px;"><?=$myrow['no_bids'];?></td>
                        <td >&nbsp;&nbsp;&nbsp;&nbsp;
						<?
						if($myrow['blocked']=='1')
						{
						?>
		<a href="user_list.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>">
		<input  name="chk[]" type="checkbox" checked 
        onClick="window.location='user_list.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>'" >
        </a>
		                 <?
                            }
						else
						
						   {
						   ?>
		<a href="user_list.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>">
        <input  name="chk[]" type="checkbox" 
        onClick="window.location='user_list.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>'" >
		</a>
                             <?
						   }	
						
						?>
						</td>
                      
                        <td align="center">
						  <table><tr><td></td>
						  
          <td><a href="user_list.php?del=<?=$myrow['id']?>"  onClick="return confirm('Are you sure to delete this User ?');"><img src="../images/category/imgdelete.gif" border="0"></a></td></tr></table>
                        </td>
                      </tr>
                      <? 
									} if(rightpaging())?>
				<tr><td colspan=7 align=center><br><?=rightpaging()?></td></tr>
                    </table>
                    </form>
                 
      
          <td width="19" valign="top" background="img/tbl-right04.gif"><img src="img/tbl-right04.gif" width="19" height="9"></td>
        
      </table>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
        <tr> 
          <td width="33"><img src="img/tbl-bot01.gif" width="33" height="12"></td>
          <td width="700" align="right" background="img/tbl-bg.gif"></td>
          <td width="33"><img src="img/tbl-right05.gif" width="35" height="12"></td>
        </tr>
      </table>
      </tr>
  
</table>

<? }else  {?>

	  <table  width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
  <tr> 
    <td width="15" valign="top">&nbsp;</td>
          <td valign="top"><br> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
        <tr> 
          <td width="33" valign="top"><img src="img/03.gif" width="33" height="23"></td>
                  
                <td background="img/bg01.gif"><strong>USER LIST </strong></td>
				<td background="img/bg01.gif"><a href="user_list.php?inactive">Total Inactive User</a></td>
				<td background="img/bg01.gif"><a href="user_list.php?online">Online User</a></td>
          <td width="35"><img src="img/04.gif" width="35" height="23"></td>
        </tr>
      </table>
	  <?
					  if(isset($_GET['search'])){
					   
					 $user_query="select id,uname,email,no_bids,blocked,gender,country,confirm,user_online,usetime from user where 1=1 ";
					  if($_GET['uname']<>''){
					  $user_query.="  and (uname like '%".$_GET['uname']."%')";
					  }	
					  
					  if($_GET['email']<>''){
					  $user_query.="  and (email like '%".$_GET['email']."%')";
					  }	
					  
					   if($_GET['gender']<>''){
					  $user_query.=" and gender='".$_GET['gender']."'";
					  }	
					  
					   if($_GET['country']<>''){
					$user_query.=" and country ='".$_GET['country']."' ";
					  }	
					  
					  
					  if($_GET['orderby']==1)
					  {
					  $user_query.=" order by rand() ";
					  }	
					  else if($_GET['orderby']==2)
					  {
					   $user_query.=" order by uname ";
					  }
					  else if($_GET['orderby']==3)
					  {
					   $user_query.=" order by email ";
					  }
					  else if($_GET['orderby']==4)
					  {
					   $user_query.=" order by no_bids ";
					  }
					 
					 }
					 else{
					 $user_query="select id,uname,email,no_bids,blocked,gender,country,confirm,user_online,usetime from user ";
					 
					 }
					
					 $limit=20;
					  $i=getStart($limit);
					  $sel_query=mysql_query(dopaging($user_query,$limit)) or die(mysql_error());
					  $num_query=mysql_num_rows($sel_query);
                     if($num_query!=0){
					  
					  ?>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
        <tr> 
          <td width="22" height="185" valign="top" background="img/tbl-left04.gif">
          <img border='0' src="img/tbl-left04.gif" width="22" height="13"></td>
          <td valign="top" align="center"> <br>		  		  		             
	
                   <form action="" method="post" enctype="multipart/form-data" name="form1"> 
                    <table width="100%" border="1" cellspacing="1" cellpadding="1" style="border-collapse:collapse;border-color:#FED267">
                      <tr bgcolor="#FED267"> 
					   <td width="4%"  align="center"><strong><font color="#FFFFFF">S.No.</font></strong></td>
                        
                        <td width="11%" >&nbsp;&nbsp;<strong><font color="#FFFFFF">User Name</font></strong></td>
						 <td width="14%" ><strong><font color="#FFFFFF">Email</font></strong></td>
						 <td width="11%" ><strong><font color="#FFFFFF">Activeness</font></strong></td>
                        <td width="11%" ><strong><font color="#FFFFFF">Online</font></strong></td>
                        <td width="12%" ><strong><font color="#FFFFFF">No. Of Bids</font></strong></td>
                        <td width="16%" height="21" align="center"><font color="#FFFFFF"><strong>Status</strong>&nbsp;&nbsp;  (select checkbox user blocked)</font></td>
						  <td width="12%" height="21" align="center"><strong><font color="#FFFFFF">Edit</font></strong></td>
                        <td width="9%" height="21" align="center"><strong><font color="#FFFFFF">Delete</font></strong></td>
                      </tr>
					  
					  <?
					  
                      while($myrow=mysql_fetch_array($sel_query)){  
					  
					  $i++;
					  
					  ?>
                      <tr onMouseOver="this.style.backgroundColor='#FFECBF'" onMouseOut="this.style.backgroundColor='#ffffff'"> 
					  <td  align="center"><?=$i;?></td>
                    
                              
                        <td >&nbsp;&nbsp;
						<a class="link5" style="font-size:12px;"  href="javascript:veiwmem(<?=$myrow['id']?>)" title="Click To View User Information" ><?=$myrow['uname']?></a></td>
						
                       
                        <td style="padding-left:5px;"><?=$myrow['email'];?></td>
						 <td style="padding-left:5px;" >
						 <? 
						 	if($myrow['confirm']=='0')
						{	
							echo "inactive";
						
						} else{
						
						echo "active";
						
						}
							?>
						 
						</td>
                        <td style="padding-left:5px;" >
						 <? 
						$num_online = mysql_num_rows(mysql_query("select id from user where id='".$myrow['id']."' and 
					  usetime > (select date_sub(now(),interval 10 minute)) and user_online='1'"));
						 
						 	if($num_online > '0')
						{	
							echo "online";
						
						} else{
						
						echo "offline";
						
						}
							?>
						 
						</td>
                        <td style="padding-left:5px;"><?=$myrow['no_bids'];?></td>
                        <td >&nbsp;&nbsp;&nbsp;&nbsp;
						<?
						if($myrow['blocked']=='1')
						{
						?>
		<a href="user_list.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>">
		<input  name="chk[]" type="checkbox" checked 
        onClick="window.location='user_list.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>'" >
        </a>
		                 <?
                            }
						else
						
						   {
						   ?>
		<a href="user_list.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>">
        <input  name="chk[]" type="checkbox" 
        onClick="window.location='user_list.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>'" >
		</a>
                             <?
						   }	
						
						?>
						</td>
                      
                   <td><a href="user_edit.php?user_id=<?=$myrow['id']?>">Edit</a></td>
						  
          <td><a href="user_list.php?del=<?=$myrow['id']?>"  onClick="return confirm('Are you sure to delete this User ?');"><img src="../images/category/imgdelete.gif" border="0"></a>
                        </td>
                      </tr>
                      <? 
									} if(rightpaging())?>
				<tr><td colspan=11 align=center><br><?=rightpaging()?></td></tr>
                    </table>
                    </form>
                 
      
          <td width="19" valign="top" background="img/tbl-right04.gif"><img src="img/tbl-right04.gif" width="19" height="9"></td>
        
      </table>
	  <? }else{
	  
	  echo "No search User";
	  }?>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodytxt">
        <tr> 
          <td width="33"><img src="img/tbl-bot01.gif" width="33" height="12"></td>
          <td align="right" background="img/tbl-bg.gif"></td>
          <td width="33"><img src="img/tbl-right05.gif" width="35" height="12"></td>
        </tr>
      </table>
      </tr>
  
</table>
<? }?>
</div>

            <br />
<br />

</div></div>
<div class="bottom_links_show"><? include("footer.php");	?></div>

</html>
</div>
</body>
</html>
