<?php
@session_start();
include('checkstate.php');
    if(@$_GET['action']=="add"){
	    if($_POST['account']==''){echo "<script type='text/javascript'>history.back();</script>";}
		$account=$_POST['account'];
		$password=$_POST['password'];
		$is=sql_select("select count(*) from guestuser where guestusername='".$account."'");
	    if($is[0][0]>0){ 
		    echo "<script type='text/javascript'>alert('该账户存在');</script>";
		    echo "<script type='text/javascript'>history.back();</script>";
		 }else{
		   $sql="insert into guestuser(guestusername,guestpwd) value('".$account."','".md5($password)."')";
		   mysql_query($sql);
		   echo "<script type='text/javascript'>history.back();</script>";
          }
	}elseif(@$_GET['action']=="domod"){
		$id=$_POST['id'];
		$account=$_POST['account'];
		$password=$_POST['password'];
		
		 $sql="update guestuser set guestusername='".$account."',guestpwd='".md5($password)."' where id=".$id;
		 mysql_query($sql);
		 echo "<script type='text/javascript'>history.back();</script>";
		 
	}elseif(@$_GET['action']=="dodel"){
	    $id=$_GET['id'];
		$sql="delete from guestusername where id=".$id;
		mysql_query($sql);
	}
?>
<!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>ETW国际案例演示</title>
<link rel="stylesheet" href="media/css.css" type="text/css" media="screen" />
</head>

<body>
<div id="main">
     <div id="top"><a href="loginout.php" title="退出">退出</a></div>
     <div id="menu"><ul>
         <li><a href="index.php">管理首页</a></li><li><a href="allcompany.php">案例企业</a></li><li><a href="keymanage.php">关键字</a></li><li><a href="accountmangage.php">帐户管理</a></li>
     </ul></div>
     
     <div id="center">
        <div id="left">
        <div class="title"><strong>行业分类案例</strong></div>
            <div class="grade"><ul>
              <li><a href="allcompany.php?id=1"><img src="img/grade_img1.jpg" />上市公司</a></li>
              <li><a href="allcompany.php?id=2"><img src="img/grade_img2.jpg" />龙头企业</a></li>
              <li><a href="allcompany.php?id=3"><img src="img/grade_img3.jpg" />中小型企业</a></li>
            </ul></div>
        </div>
        
        <div id="right">
          <div class="location"><strong>当前位置 : 管理首页 >> 帐户管理</strong></div>
          <div id="content">
              <div class="tablelist">
    <?php if(@$_GET['action']=="mod"){
	    $id=$_GET['id'];
		$sql="select * from guestuser where id=".$id; $result=mysql_query($sql);
		$rs=mysql_fetch_array($result);
	?>
      <form action="accountmangage.php?action=domod" method="post">           
    <table width="688" border="0" class="table2" style="line-height:30px;">
  <tr><input type="hidden" name="id" value="<?php echo $id; ?>" />
    <td colspan="2" style="padding-left:100px;">修 改  账 户 资 料</td>
  </tr>
  <tr>
    <td width="106" align="right">账户号: &nbsp; </td>
    <td width="564">&nbsp; <input type="text" name="account"  size="20" value="<?php echo $rs['guestusername']; ?>" /> 由字母和数字组成的8位字符串</td>
  </tr>
  <tr>
    <td width="106" align="right">账户密码: &nbsp; </td>
    <td width="564">&nbsp; <input type="text" name="password"  size="" value="" /> </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;<input type="submit" name="submit" value="修 改" /> <input type="reset" name="reset" value="重 填" /></td>
  </tr>
</table></form> 
<div id="clear"></div>

    <?php  } else{?>          
   <form action="accountmangage.php?action=add" method="post">           
    <table width="688" border="0" class="table2" style="line-height:30px;">
  <tr>
    <td colspan="2" style="padding-left:100px;">添 加 新 账 户</td>
  </tr>
  <tr>
    <td width="106" align="right">新账户号: &nbsp; </td>
    <td width="564">&nbsp; <input type="text" name="account"  size="" /> 由字母和数字组成的8位字符串</td>
  </tr>
  <tr>
    <td width="106" align="right">账户密码: &nbsp; </td>
    <td width="564">&nbsp; <input type="text" name="password"  size="" /> </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;<input type="submit" name="submit" value="添 加" /> <input type="reset" name="reset" value="重 填" /></td>
  </tr>
</table></form><?php } ?>
<div id="clear"></div>
  <table width="645" border="1" bordercolor="#336699" cellpadding="0" cellspacing="0" class="tables" style="text-align:center">
  <tr>
    <td width="97">序号</td>
    <td width="105">用户名</td>
    <td width="327">远程登陆地址</td>
    <td width="106">修改/删除</td>
  </tr>
  <?php $a=1; $sql="select * from guestuser"; $result=mysql_query($sql);
        while($rs=mysql_fetch_array($result)){?>
  <tr>
    <td><?php echo $a; $a++; ?></td>
    <td><?php echo $rs['guestusername'];?></td>
    <td><?php echo "http://case.etwinternational.com//guestlogin.php?str1=".$rs['guestpwd']."|".$rs['guestusername'];?></td>
    <td><a href="accountmangage.php?action=mod&id=<?php echo $rs['id']; ?>">修改</a>/<a href="accountmangage.php?action=dodel&id=<?php echo $rs['id']; ?>">删除</a></td>
  </tr><?php } ?>
</table>

            </div>
          </div>
        </div>
     </div>
     
     <div id="foot"><P>copy right &copy; 2008-2009  <font color="#990000">ETW International</font></P></div>
</div>
</body>
</html>
