<? 
//-----------------------------------------------------------------------------
//    ID002同学录 单班级 (PHP & MySQL) 1.0 标准版
//-----------------------------------------------------------------------------
//    Copyright(C) aNErG, 2003. All rights reserved
//
//    技术支持 http://anerg.126.com
//-----------------------------------------------------------------------------
//    本软件对个人完全免费使用
//
//    如用于商业用途,您必须与我联系并支付RMB ￥20
//-----------------------------------------------------------------------------
if (empty($HTTP_COOKIE_VARS["class_username"]))
{echo "请先<a herf=index.php>登录</a>！";exit;}
  include ('conn.php');
	if($mod==""){
	  $query="SELECT photoid,photourl,photoname,author,uptime FROM photomsg where photoid='$photoid'";
      $result=mysql_db_query("$dbname",$query);
	   $r=mysql_fetch_array($result);
	   $photourl=$r["photourl"];
       $photoname=$r["photoname"];
	   $author=$r["author"];
       $uptime=$r["uptime"];
	   $photoid=$r["photoid"];

  ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>班级相册</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>

<body>
<div align="center"><? echo"$photoname"; ?></div>

<div align="center"></div>
<table border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#7597B0">
  <tr>
    <td><div align="center"><? echo"<img src=$photourl>"; ?></div></td>
  </tr>
  <tr>
    <td><div align="center">本图片由<? echo"&nbsp;<a href='listuser.php?name=$author'>$author</a>&nbsp;上传于<br>$uptime"; ?></div></td>
</table>
<? if(($HTTP_COOKIE_VARS["class_username"])==$author){
echo "<div align='center'><a href=$PHP_SELF?mod=edit&photoid=$photoid><img src=images/edit.gif width='16' height='16' border='0'></a>&nbsp;<a href=$PHP_SELF?mod=del&photoid=$photoid&photourl=$photourl><img src=images/del.gif width='16' height='16' border='0'></a></div>" ;} ?>
<div align="center"><a href="javascript:window.close()">==关闭本窗口==</a></div>
  <?php require("bottom.php"); ?>
</body>
</html>
<? }
if($mod==edit){
if (empty($HTTP_COOKIE_VARS["class_username"]))
{echo "请先<a herf=index.php>登录</a>！";exit;}
	  $query="SELECT photoid,photoname FROM photomsg where photoid='$photoid'";
      $result=mysql_db_query("$dbname",$query);
	   $r=mysql_fetch_array($result);
       $photoname=$r["photoname"];
	   $photoid=$r["photoid"];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>班级相册</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<div align="center">
        <form action="<? echo "$PHP_SELF?mod=updat&photoid=$photoid"; ?>" method="post">
          <textarea name="photoname" cols="19" rows="5"><? echo"$photoname"; ?></textarea>
          &nbsp; 
          <input type="submit" name="Submit" value=" 更新 ">
          
        </form>
      </div>
<? } 
if($mod==updat){
if (empty($HTTP_COOKIE_VARS["class_username"]))
{echo "请先<a herf=index.php>登录</a>！";exit;}
$query="update photomsg set photoname='$photoname' where photoid='$photoid'";
$result=mysql_db_query("$dbname",$query);
if(mysql_affected_rows()==1){
echo"更新成功！自动返回。";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>资料更新</title>
<link href="css.css" rel="stylesheet" type="text/css">
<meta http-equiv=Refresh content="2; url=<? echo "$PHP_SELF?photoid=$photoid"; ?>">
</head>
<? } 
else{echo"出错了！请联系管理员！";}
}
if($mod==del){
if (empty($HTTP_COOKIE_VARS["class_username"]))
{echo "请先<a herf=index.php>登录</a>！";exit;}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>资料更新</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>
<div align="center"><a href=<? echo"$PHP_SELF?mod=sdel&photoid=$photoid&photourl=$photourl"; ?>>==确定删除?==</a></div>
</body>
<? }
if($mod==sdel)
{ 
if (empty($HTTP_COOKIE_VARS["class_username"]))
{echo "请先<a herf=index.php>登录</a>！";exit;}
$query="delete from photomsg where photoid='$photoid'";
$result=mysql_db_query("$dbname",$query);
if(mysql_affected_rows()==1){
unlink($photourl);
echo"删除成功！自动返回。";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>资料更新</title>
<link href="css.css" rel="stylesheet" type="text/css">
<meta http-equiv=Refresh content="2; url=javascript:window.close()">
</head>
<body>
<? }
else{echo"出错了，请联系管理员！";}?>
</body>
  <?php require("bottom.php"); } ?>