<%@language=vbscript codepage=936 %>
<%
option explicit
response.buffer=true	
Const PurviewLevel=2
Const CheckChannelID=4
Const PurviewLevel_Photo=3
%>
<!--#include file="inc/conn1.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="Admin_ChkPurview.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/admin_code_Photo.asp"-->
<%
dim PhotoID,rsPhoto,sql,FoundErr,ErrMsg,PurviewChecked
dim ClassID,tClass,ClassName,RootID,ParentID,Depth,ParentPath,ClassMaster
dim SkinID,LayoutID,SkinCount,LayoutCount,BrowsePurview,AddPurview
PurviewChecked=False
FoundErr=False
PhotoID=trim(request("PhotoID"))
if PhotoID="" then
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>请指定要修改的图片ID</li>"
	call WriteErrMsg()
	call CloseConn()
	response.end
else
	PhotoID=CLng(PhotoID)
end if
sql="select * from Photo where PhotoID=" & PhotoID & ""
Set rsPhoto= Server.CreateObject("ADODB.Recordset")
rsPhoto.open sql,conn,1,1
if rsPhoto.bof and rsPhoto.eof then
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>找不到图片</li>"
	call WriteErrMsg()
else
	ClassID=rsPhoto("ClassID")
	set tClass=conn.execute("select ClassName,RootID,ParentID,Depth,ParentPath,ClassMaster From PhotoClass where ClassID=" & ClassID)
	if tClass.bof and tClass.eof then
		founderr=True
		ErrMsg=ErrMsg & "<br><li>找不到指定的栏目</li>"
	else
		ClassName=tClass(0)
		RootID=tClass(1)
		ParentID=tClass(2)
		Depth=tClass(3)
		ParentPath=tClass(4)
		ClassMaster=tClass(5)
	end if
	if rsPhoto("Editor")=AdminName and rsPhoto("Passed")=False then
		PurviewChecked=True
	else
		if AdminPurview=1 or AdminPurview_Photo<=2 then
			PurviewChecked=True
		else
			PurviewChecked=CheckClassMaster(ClassMaster,AdminName)
			if PurviewChecked=False and ParentID>0 then
				set tClass=conn.execute("select ClassMaster from PhotoClass where ClassID in (" & ParentPath & ")")
				do while not tClass.eof
					PurviewChecked=CheckClassMaster(tClass(0),AdminName)
					if PurviewChecked=True then exit do
					tClass.movenext
				loop
			end if
		end if
		if PurviewChecked=False then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>对不起，您的权限不够，不能修改此张图片！</li>"
		end if
	end if
end if
if FoundErr=True then
	call WriteErrMsg()
else
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="MicroPhoto FrontPage 3.0">
<title>修改图片</title>
<link rel="stylesheet" type="text/css" href="Admin_Style.css">
<script language = "JavaScript">
function CheckForm()
{
  if (document.myform.ClassID.value=="")
  {
    alert("图片所属栏目不能指定为含有子栏目的栏目！");
	document.myform.ClassID.focus();
	return false;
  }
  if (document.myform.ClassID.value==0)
  {
    alert("图片所属栏目不能指定为外部栏目！");
	document.myform.ClassID.focus();
	return false;
  }

  if (document.myform.PhotoName.value=="")
  {
    alert("图片名称不能为空！");
	document.myform.PhotoName.focus();
	return false;
  }
  if (document.myform.Keyword.value=="")
  {
    alert("关键字不能为空！");
	document.myform.Keyword.focus();
	return false;
  }
  if (document.myform.PhotoUrl_Thumb.value=="")
  {
    alert("缩略图地址不能为空！");
	document.myform.PhotoUrl_Thumb.focus();
	return false;
  }
  if (document.myform.PhotoSize_Thumb.value=="")
  {
    alert("缩略图文件大小不能为空！");
	document.myform.PhotoSize_Thumb.focus();
	return false;
  }
  if (document.myform.PhotoUrl.value=="")
  {
    alert("原始图片地址不能为空！");
	document.myform.PhotoUrl.focus();
	return false;
  }
  if (document.myform.PhotoSize.value=="")
  {
    alert("原始图片文件大小不能为空！");
	document.myform.PhotoSize.focus();
	return false;
  }
}
</script>
<style type="text/css">
<!--
body {	background-color: #FFFFFF;
	margin-right: 8px;
	margin-bottom: 8px;
	margin-left: 8px;
	margin-top: 0px;
}
-->
</style>
</head>
<body>
<form method="POST" name="myform" onSubmit="return CheckForm();" action="Admin_PhotoSave.asp" target="_self">
  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td width="1" bgcolor="#D6D5D9"></td>
      <td height="34" align=left bgcolor="#F8F8F9"><strong>&nbsp;&nbsp;管理导航：</strong><a href="Admin_PhotoManage.asp">图片管理</a>&nbsp;|&nbsp;<a href="Admin_PhotoAdd.asp">添加图片</a>&nbsp;| <a href="Admin_PhotoRecyclebin.asp">图片回收站管理</a>&nbsp;|&nbsp;<a href="Admin_PhotoComment.asp">图片评论管理</a></td>
      <td width="1" bgcolor="#D6D5D9"></td>
    </tr>
    <tr>
      <td width="1" bgcolor="#F8F8F9"></td>
      <td height="1" bgcolor="#D6D5D9" ></td>
      <td width="1" bgcolor="#F8F8F9"></td>
    </tr>
  </table>
  <table width="100%" height="8" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <table width="100%" border="0" cellpadding="6" cellspacing="1" bgcolor="#CCCCCC">
    <tr > 
            <td height="30" colspan="3" align="center" bgcolor="#F8F8F9"><strong>-- 修改相片(图片) --</strong></td>
      </tr>
    <tr>
      <td width="100" align="right" bgcolor="#FFFFFF"><strong>所属分类：</strong></td>
      <td colspan="2" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><%
			if AdminPurview=1 or AdminPurview_Photo<=2 then
			 	response.write "<select name='ClassID'>"	
				call Admin_ShowClass_Option(3,rsPhoto("ClassID"))
				response.write "</select></td><td>"
				response.write "<font color='#FF0000'><strong>注意：</strong></font><font color='#0000FF'>1、不能指定为含有子栏目的栏目，或者外部栏目"
			 else
			 	call Admin_ShowPath2(ParentPath,ClassName,Depth)
				response.write "<input type='hidden' name='ClassID' value='" & rsPhoto("ClassID") & "'>"
			 end if
			 %>            </td>
            <td>&nbsp;</td>
          </tr>
      </table></td>
    </tr>
    <tr>
      <td width="100" align="right" bgcolor="#FFFFFF"><strong>图片名称：</strong></td>
      <td colspan="2" bgcolor="#FFFFFF"><input name="PhotoName" type="text" id="PhotoName" value="<%=rsPhoto("PhotoName")%>" size="50" maxlength="255">
          <font color="#FF0000">*</font></td>
    </tr>
    <tr>
      <td width="100" align="right" bgcolor="#FFFFFF"><strong>关键字：</strong></td>
      <td colspan="2" bgcolor="#FFFFFF"><input name="Keyword" type="text"
           id="Keyword" value="<%=mid(rsPhoto("Keyword"),2,len(rsPhoto("Keyword"))-2)%>" size="50" maxlength="255">
        <font color="#FF0000">*</font><font color="#0000FF">中间用<font color="#FF0000">“|”</font>隔开。不能出现&quot;&quot;'*?,.()等字符。</font></td>
    </tr>
<tr bgcolor="#FFFFFF">
                              <td  align="right"><strong>相 &nbsp;&nbsp;片：</strong></td>
                              <td colspan="2" >
                                <table border="0" cellpadding="0" cellspacing="0">
                                  <tr>
                                    <td width="258" valign="top"><input name="PhotoUrl_Thumb" type="text" id="PhotoUrl_Thumb" value="<%=rsphoto("PhotoUrl_Thumb")%>" size="40" maxlength="200">
                                      <input name="PhotoUrl_Thumbsm" type="hidden" id="PhotoUrl_Thumbsm" size="40" maxlength="200" value="<%=rsphoto("PhotoUrl_Thumbsm")%>">
                                    <input name="PhotoUrl" type="hidden" id="PhotoUrl" size="40" maxlength="200" value="<%=rsphoto("PhotoUrl")%>"></td>
                                    <td><iframe style="top:2px" id="UploadFiles" src="upload_Photos.asp?PhotoUrlID=0" frameborder=0 scrolling=no width="290" height="25"></iframe></td>
                                  </tr>
                                </table>                              </td>
                            </tr>  

    <tr>
      <td width="100" align="right" valign="middle" bgcolor="#FFFFFF"><strong>图片简介：</strong><br>
      支持各种UBB代码</td>
      <td colspan="2" bgcolor="#FFFFFF"><textarea name="PhotoIntro" cols="80" rows="5" id="PhotoIntro"><%=rsPhoto("PhotoIntro")%></textarea>
       
              <input name="AuthorHomepage" type="hidden"
           id="AuthorHomepage" value="http://" size="28" maxlength="100">
              <input name="AuthorEmail" type="hidden" id="AuthorEmail" size="28" maxlength="100">
                                  <input name="Author" type="hidden"
           id="Author3" size="17" maxlength="100" ><input name="PhotoSize_Thumb" type="hidden" id="PhotoSize_Thumb" size="1" maxlength="10" value="<%=rsPhoto("PhotoSize_Thumb")%>">
		   
                                <input name="PhotoSize" type="hidden" id="PhotoSize5" size="1" maxlength="10" value="<%=rsPhoto("PhotoSize")%>"></td>
    </tr>

    <%if AdminPurview=1 or AdminPurview_Photo<=2 then%>
    <tr>
      <td width="100" align="right" bgcolor="#FFFFFF"><strong>图片属性：</strong></td>
      <td bgcolor="#FFFFFF"><input name="OnTop" type="checkbox" id="OnTop" value="yes" <%if rsPhoto("OnTop")=True then response.write " checked"%>>
        固顶图片&nbsp;&nbsp;&nbsp;
        <input name="Hot" type="checkbox" id="Hot" value="yes" disabled>
        热门图片&nbsp;&nbsp;&nbsp;
        <input name="Elite" type=checkbox id="Elite" value="yes"<%if rsPhoto("Elite")=True then response.write " checked"%>>
      推荐图片</td>
      <td bgcolor="#FFFFFF"><strong>图片评分等级：</strong>
          <select name="Stars" id="Stars">
            <option value="5" <%if rsPhoto("Stars")=5 then response.write " selected"%>>★★★★★</option>
            <option value="4" <%if rsPhoto("Stars")=4 then response.write " selected"%>>★★★★</option>
            <option value="3" <%if rsPhoto("Stars")=3 then response.write " selected"%>>★★★</option>
            <option value="2" <%if rsPhoto("Stars")=2 then response.write " selected"%>>★★</option>
            <option value="1" <%if rsPhoto("Stars")=1 then response.write " selected"%>>★</option>
            <option value="0" <%if rsPhoto("Stars")=0 then response.write " selected"%>>无</option>
          </select>
          <font color="#FF0000">*</font></td>
    </tr>
    <tr>
      <td width="100" align="right" bgcolor="#FFFFFF"><strong>查看次数：</strong></td>
      <td colspan="2" bgcolor="#FFFFFF">本日：
        <input name="DayHits" type="text" id="DayHits" value="<%=rsPhoto("DayHits")%>" size="10" maxlength="10">
        &nbsp;&nbsp;&nbsp;&nbsp;本周：
        <input name="WeekHits" type="text" id="WeekHits" value="<%=rsPhoto("WeekHits")%>" size="10" maxlength="10">
        &nbsp;&nbsp;&nbsp;&nbsp;本月：
        <input name="MonthHits" type="text" id="MonthHits" value="<%=rsPhoto("MonthHits")%>" size="10" maxlength="10">
        &nbsp;&nbsp;&nbsp;&nbsp;总计：
      <input name="Hits" type="text" id="Hits" value="<%=rsPhoto("Hits")%>" size="10" maxlength="10"></td>
    </tr>
    <%end if%>
    <tr>
      <td width="100" align="right" bgcolor="#FFFFFF"><strong>查看等级：</strong></td>
      <td colspan="2" bgcolor="#FFFFFF"><select name="PhotoLevel" id="select">
          <option value="9999" <%if rsPhoto("PhotoLevel")=9999 then response.write " selected"%>>游客</option>
          <option value="999" <%if rsPhoto("PhotoLevel")=999 then response.write " selected"%>>注册用户</option>
          <option value="99" <%if rsPhoto("PhotoLevel")=99 then response.write " selected"%>>收费用户</option>
          <option value="9" <%if rsPhoto("PhotoLevel")=9 then response.write " selected"%>>VIP用户</option>
          <option value="5" <%if rsPhoto("PhotoLevel")=5 then response.write " selected"%>>管理员</option>
        </select>
      &nbsp;&nbsp;&nbsp;<font color="#0000FF">只有具有相应权限的人才能查看此图片。</font></td>
    </tr>
    <tr>
      <td width="100" align="right" bgcolor="#FFFFFF"><strong>查看点数：</strong></td>
      <td colspan="2" bgcolor="#FFFFFF"><input name="PhotoPoint" type="text" id="PhotoPoint" value="<%=rsPhoto("PhotoPoint")%>" size="5" maxlength="3">
      &nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000FF">如果大于0，则用户查看此图片时将消耗相应点数。（对游客和管理员无效）</font></td>
    </tr>
    <%if AdminPurview=1 or AdminPurview_Photo<=2 then%>
    <tr>
      <td width="100" align="right" bgcolor="#FFFFFF"><strong>录入时间：</strong></td>
      <td colspan="2" bgcolor="#FFFFFF"><input name="UpdateTime" type="text" id="UpdateTime" value="<%=rsPhoto("UpdateTime")%>" maxlength="50">
      时间格式为“年-月-日 时:分:秒”，如：<font color="#0000FF">2003-5-12 12:32:47
      <input name="Passed" type="hidden" id="Passed" value="yes" checked>
      </font></td>
    </tr>

    <%end if%>
  </table>
  <div align="center"> 
    <p>
      <input name="PhotoID" type="hidden" id="PhotoID" value="<%=PhotoID%>"> 
      <input name="Action" type="hidden" id="Action" value="Modify">
      <input
  name="Add" type="submit"  id="Add" value="保存修改结果" style="cursor:hand;">
      &nbsp; 
      <input name="Cancel" type="button" id="Cancel" value=" 取 消 " onClick="window.location.href='Admin_PhotoManage.asp'" style="cursor:hand;">
    </p>
  </div>
</form>
</body>
</html>
<%
end if
rsPhoto.close
set rsPhoto=nothing
call CloseConn()
%>
