<? if 
//-----------------------------------------------------------------------------
//    ID002同学录 单班级 (PHP & MySQL) 1.0 标准版
//-----------------------------------------------------------------------------
//    Copyright(C) aNErG, 2003. All rights reserved
//
//    技术支持 http://anerg.126.com
//-----------------------------------------------------------------------------
//    本软件对个人完全免费使用
//
//    如用于商业用途,您必须与我联系并支付RMB ￥20
//-----------------------------------------------------------------------------
(empty($HTTP_COOKIE_VARS["class_username"]))
{echo "请先<a herf=index.php>登录</a>！";exit;} 
if($mod==""){
 ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>上传相片</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div align="center">
        <form enctype="multipart/form-data" action="<? echo "$PHP_SELF?mod=upload"; ?>" method="post">
		<input type="hidden" name="MAX_FILE_SIZE" value="1200000">
		  <div align="center">请选择图片&nbsp;(不得大于1M)</div>
		<input type="file" name="upfile">
          <br>
          <textarea name="photoname" cols="19" rows="5">图片文字介绍</textarea>
          &nbsp; 
          <input type="submit" name="Submit" value=" 上传 ">
          <br>
          <font color="#FF0000">注意：</font>有的空间不支持中文名，所以图片名最好不要是中文！ 
        </form>
      </div></td>
  </tr>
</table>
<?php require("bottom.php"); }
if($mod==upload){
include ('conn.php');
require('function.php');
if($upfile_name!=""){
$upfile_name=date("ymjHiU").$upfile_name;
if(!eregi("jpg$",$upfile_name) && !eregi("jpeg$",$upfile_name) && !eregi("gif$",$upfile_name) && !eregi("bmp$",$upfile_name))
{echo"图片格式不正确！只能是jpg,jpeg,gif和bmp文件.";exit;}
@$upflag=copy($upfile,"upfile/$upfile_name");
if($upflag==TURE){
$author=$HTTP_COOKIE_VARS["class_username"];
$photoname=$HTTP_POST_VARS["photoname"];
$uptime=date("y-m-j H:i:U");
$photourl="upfile/$upfile_name";
$query="INSERT INTO photomsg VALUES('','$photourl','$photoname','$author','$uptime')";
$result=mysql_db_query("$dbname",$query);
if(mysql_affected_rows()==1)
{
echo"<p>相片上传成功</p>";
echo"<br><p>地址为:&nbsp;&nbsp;";
echo"upfile/$upfile_name";
echo"</p>";
}
}else{echo"上传不成功！如果不是图片过大的话，请联系管理员！";}
}else{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>
<?php require("bottom.php"); }?>