<?
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_dummy.php");
exit();
}   

if($_GET['del'])
{
 $del_query=mysql_query("delete from user where id=".$_GET['del']);
  $res=mysql_query("select id from user where dummy='1'");
  $x=1;
  while($rec=mysql_fetch_array($res))
  {
  mysql_query("update user set dummy_order='$x' where id='$rec[0]'");
  $x++;
  } 
}

if($_POST['adduser'] && $_POST['user_name']!='')
{
$max_dummy=mysql_fetch_array(mysql_query("select dummy_order from user order by dummy_order desc limit 1"));
$dummy_order=$max_dummy[0] + 1;

if(mysql_num_rows(mysql_query("select id from user where uname='".$_POST['user_name']."'"))==0)
mysql_query("insert into user set uname='".$_POST['user_name']."',dummy='1',dummy_order='".$dummy_order."'");
}
if($_POST['edituser'] && $_POST['user_name']!='')
{
if(mysql_num_rows(mysql_query("select id from user where uname='".$_POST['user_name']."'"))==0)
mysql_query("update user set uname='".$_POST['user_name']."' where id='".$_GET['edit']."'");
}


		
		
$sel_query=mysql_query("select id,uname,blocked from user where dummy='1'");

?>
<!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" />

<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" class="bodytxt">
  <tr> 
    <td width="15" valign="top">&nbsp;</td>
          <td valign="top">
           <form name="frm" action="" method="post">
     <? if($_GET['add']==1)
	 {?>     
         
        <strong> Enter Name of dummy user : </strong> <input type="text" name="user_name" class="inputtext"  />
         <input type="submit" name="adduser" class="inputsubmit" value="Add" />
          
     <? }  
      if($_GET['edit'])
	 {
	 $rec=mysql_fetch_array(mysql_query("select uname from user where id='".$_GET['edit']."'"));
	 ?>     
          
        <strong> Enter Name of dummy user : </strong> <input type="text" name="user_name" value="<?=$rec[0]?>" class="inputtext"  />
         <input type="submit" name="edituser" class="inputsubmit" value="Update" />
          
     <? }?>     
          
          
         <br /> <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="236" background="img/bg01.gif"><strong>Dummy Users </strong></td>
				<td width="150" background="img/bg01.gif">&nbsp;</td>
				<td width="281" background="img/bg01.gif">&nbsp;<a href="user_dummy.php?add=1">Add dummy users</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>		  		  		             
	
                  
                    <table width="100%" border="1" cellspacing="1" cellpadding="1" style="border-collapse:collapse;border-color:#FED267">
                      <tr bgcolor="#FED267"> 
					   <td width="15%"  align="center"><strong><font color="#FFFFFF">S.No.</font></strong></td>
                        <td width="40%" >&nbsp;&nbsp;<strong><font color="#FFFFFF">Username</font></strong></td>
					    <td width="14%" 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="18%" 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 >&nbsp;&nbsp;&nbsp;&nbsp;
						<?
						if($myrow['blocked']=='1')
						{
						?>
		<a href="user_dummy.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>">
		<input  name="chk[]" type="checkbox" checked 
        onClick="window.location='user_dummy.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>'" >
        </a>
		                 <?
                            }
						else
						
						   {
						   ?>
		<a href="user_dummy.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>">
        <input  name="chk[]" type="checkbox" 
        onClick="window.location='user_dummy.php?blocked=<?=$myrow['blocked'];?>&id=<?=$myrow['id']?>'" >
		</a>
                             <?
						   }	
						
						?>						</td>
                      
                   <td><a href="user_dummy.php?edit=<?=$myrow['id']?>">Edit</a></td>
						  
          <td><a href="user_dummy.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=6 align=center><br><?=rightpaging()?></td></tr>
                    </table>
                 
                 
      	  </td>	
          <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 align="right" background="img/tbl-bg.gif"></td>
          <td width="33"><img src="img/tbl-right05.gif" width="35" height="12"></td>
        </tr>
      </table>
      
      </form>
      
          </td>
      </tr>
  
</table>

</div>

            <br />
<br />

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

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