<%@language=vbscript codepage=936 %>
<%
response.buffer=true	
%>
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/Conn_User.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="inc/ubbcode.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/admin_code_flv.asp"-->

<%
if CheckUserLogined()=False then
	response.Redirect "User_Login.asp"
end if
dim Action,rs,sql,ErrMsg,FoundErr,ObjInstalled
dim PhotoID,ClassID,PhotoName,Keyword,Author,AuthorEmail,AuthorHomepage
dim PhotoUrl_Thumb,PhotoUrl_Thumbsm,PhotoUrl,styletype,PhotoUrl2,PhotoUrl3,PhotoUrl4,PhotoSize_Thumb,PhotoSize,PhotoSize2,PhotoSize3,PhotoSize4
dim Passed,PhotoIntro,UpdateTime,Editor
dim tClass,ClassName,Depth,ParentPath,Child,i
ObjInstalled=IsObjInstalled("Scripting.FileSystemObject")
FoundErr=false
Action=trim(request("Action"))
PhotoID=Trim(Request.Form("PhotoID"))
ClassID=trim(request.form("ClassID"))
PhotoName=trim(request.form("PhotoName"))
Keyword=trim(request.form("Keyword"))
Author=trim(request.form("Author"))
AuthorEmail=trim(request.form("AuthorEmail"))
styletype=trim(request.form("styletype"))
AuthorHomepage=trim(request.form("AuthorHomePage"))
PhotoUrl_Thumb=trim(request.form("PhotoUrl_Thumb"))
PhotoUrl_Thumbsm=trim(request.form("PhotoUrl_Thumbsm"))
PhotoUrl=trim(request.form("PhotoUrl"))
PhotoUrl2=trim(request.form("PhotoUrl2"))
PhotoUrl3=trim(request.form("PhotoUrl3"))
PhotoUrl4=trim(request.form("PhotoUrl4"))
PhotoSize_Thumb=trim(request.form("PhotoSize_Thumb"))
PhotoSize=trim(request.form("PhotoSize"))
PhotoSize2=trim(request.form("PhotoSize2"))
PhotoSize3=trim(request.form("PhotoSize3"))
PhotoSize4=trim(request.form("PhotoSize4"))
PhotoIntro=trim(request.form("PhotoIntro"))

Editor=trim(Request.Cookies("asp163")("UserName"))

if Action="" then
	FoundErr=True
	ErrMsg=ErrMsg & "<br><li>参数不足</li>"
else
	call SavePhoto()
end if
if founderr=true then
	call WriteErrMsg()
else
	call SaveSuccess()
end if
call CloseConn()


sub SavePhoto()
	if ClassID="" then
		founderr=true
		errmsg=errmsg & "<br><li>视屏所属分类不能为空</li>"
	else
		ClassID=CLng(ClassID)
		if ClassID=0 then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>视屏所属分类不能为空</li>"
		elseif ClassID=-1 then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>你没有在你指定的栏目添加视屏的权限</li>"
		else
			set tClass=conn.execute("select ClassName,Depth,ParentPath,Child,LinkUrl,AddPurview From flvClass where ClassID=" & ClassID)
			if tClass.bof and tClass.eof then
				founderr=True
				ErrMsg=ErrMsg & "<br><li>找不到指定的栏目</li>"
			else
				ClassName=tClass(0)
				Depth=tClass(1)
				ParentPath=tClass(2)
				Child=tClass(3)
				if Child>0 then
					FoundErr=True
					ErrMsg=ErrMsg & "<br><li>指定的栏目有下属子栏目</li>"
				end if
				if tClass(4)<>"" then
					FoundErr=True
					ErrMsg=ErrMsg & "<br><li>不能指定外部栏目</li>"
				end if
				
			end if
		end if
	end if
	if PhotoName="" then
		founderr=true
		errmsg=ErrMsg & "<br><li>视屏名称不能为空</li>"
	end if
	if Keyword="" then
		founderr=true
		errmsg=errmsg & "<br><li>请输入视屏关键字</li>"
	end if
	if PhotoUrl_Thumb="" then
		founderr=true
		errmsg=ErrMsg & "<br><li>缩略图地址不能为空</li>"
	end if
	if PhotoSize_Thumb="" then
		PhotoSize_Thumb=33
	else
		PhotoSize_Thumb=Clng(PhotoSize_Thumb)
	end if
	if PhotoUrl="" then
		founderr=true
		errmsg=errmsg & "<br><li>原始视屏地址不能为空</li>"
	end if
	if PhotoSize="" then
		founderr=true
		errmsg=errmsg & "<br><li>原始视屏文件大小不能为空</li>"
	else
		PhotoSize=Clng(PhotoSize)
	end if
	
	if FoundErr=True then
		exit sub
	end if
		
	Keyword="|" & ReplaceBadChar(Keyword) & "|"
	if PhotoSize2="" then
		PhotoSize2=0
	else
		PhotoSize2=Clng(PhotoSize2)
	end if
	if PhotoSize3="" then
		PhotoSize3=0
	else
		PhotoSize3=Clng(PhotoSize3)
	end if
	if PhotoSize4="" then
		PhotoSize4=0
	else
		PhotoSize4=Clng(PhotoSize4)
	end if

	UpdateTime=now()
	
	set rs=server.createobject("adodb.recordset")
	if Action="Add" then
		sql="select * from flv where photoid=1" 
		rs.open sql,conn,1,3
		rs.addnew
		call SaveData()
		rs.update
		rs.close
		sql="select top 1 * from flv order by PhotoID desc"
		rs.open sql,conn,1,1
			PhotoID=rs("PhotoID")
			Passed=rs("passed")
		rs.close
	elseif Action="Modify" then
  		if PhotoID="" then
			founderr=true
			errmsg=errmsg & "<br><li>不能确定PhotoID的值</li>"
		else
			PhotoID=Clng(PhotoID)
			sql="select * from flv where Photoid=" & PhotoID
			rs.open sql,conn,1,3
			if rs.bof and rs.eof then
				founderr=true
				errmsg=errmsg & "<br><li>找不到此视屏，可能已经被其他人删除。</li>"
 			else
				call SaveData()
				rs.update
				Passed=rs("Passed")
				rs.close
			end if
		end if
	else
		FoundErr=True
		ErrMsg="<br><li>参数错误!</li>"
	end if
	set rs=nothing
end sub

sub SaveData()
	rs("ClassID")=ClassID
	rs("PhotoName")=PhotoName
	rs("Keyword")=Keyword
	rs("Author")=Author
	rs("AuthorEmail")=AuthorEmail
	rs("AuthorHomepage")=AuthorHomepage
	rs("PhotoUrl_Thumb")=PhotoUrl_Thumb
	rs("PhotoUrl_Thumbsm")=PhotoUrl_Thumbsm
	rs("styletype")=styletype
	rs("PhotoUrl")=PhotoUrl
	rs("PhotoUrl2")=PhotoUrl2
	rs("PhotoUrl3")=PhotoUrl3
	rs("PhotoUrl4")=PhotoUrl4
	rs("PhotoSize_Thumb")=PhotoSize_Thumb
	rs("PhotoSize")=PhotoSize
	rs("PhotoSize2")=PhotoSize2
	rs("PhotoSize3")=PhotoSize3
	rs("PhotoSize4")=PhotoSize4
	rs("PhotoIntro")=PhotoIntro
	rs("Hits")=0
	rs("DayHits")=0
	rs("WeekHits")=0
	rs("MonthHits")=0
	rs("PhotoLevel")=9999
	rs("PhotoPoint")=0
	rs("Stars")=0
	rs("UpdateTime")=UpdateTime
	rs("Passed")=1
	rs("OnTop")=0
	rs("Elite")=0
	rs("Editor")=Editor
	rs("Deleted")=0
		
end sub

sub SaveSuccess()
%>
<!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"  xml:lang="zh-CN" lang="zh-CN">
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide
function killErrors() {
return true;
}
window.onerror = killErrors;
// -->
</SCRIPT>


	<script type=text/javascript>var xijuan={channel:"index"}</script>
<script type=text/javascript src="Inc/main.js"></script>
	<title>芜湖播客家园</title>
	<meta http-equiv=Content-Type content=text/html; charset=GB2312 />
	<meta name=Keywords CONTENT=视频，播客，大头贴，搞笑，原创，自拍，专题>
	<meta name=Description CONTENT=516show.cn--全国最大的免费的视频，拥有一个属于你自己的家园。 />


<!--#include file="top1.asp"-->

<script language="JavaScript" type="text/javascript">
	function chkfrm(){
		
		if (document.Myform.Keywords.value==""){
			alert('请输入要检索的关键字！');
			document.Myform.Keywords.focus();
			return false;
		}
		
		
			var Obj = document.getElementsByName("mysort");
			for(i=0;i<Obj.length;i++){
				if(Obj[i].selected){
					if (Obj[i].value=="flv"){
						document.Myform.action="flv_search.asp";
					}else if (Obj[i].value=="zone"){
						document.Myform.action="user_search.asp";
					}else if (Obj[i].value=="blog"){
						document.Myform.action="blog_search.asp";
					}else if (Obj[i].value=="photo"){
						document.Myform.action="photo_search.asp";
					}else{
						document.Myform.action="user_search.asp";
					}
				}
			}

		
		return true;
	}
</script>
<form id="Myform" name="Myform" onSubmit="return chkfrm();" action="" method=post>
    <div id=SearchBlock>
      <div id=search>
<input name="Keywords" type="text" id="Keywords" class="input2"size="45" value="美女" onMouseOver="this.focus()" onFocus="this.select()" onClick="if (this.value=='美女') this.value=''"  />


             <select name="mysort" id="mysort" size="1" class="input2"> 
             <option selected value="flv" name="mysort" id="mysort">用户视屏</option>
             <option value="zone" name="mysort" id="mysort">注册用户</option>
             <option value="photo" name="mysort" id="mysort">用户相册</option>
             <option value="blog" name="mysort" id="mysort">用户日志</option>
             </select> &nbsp;
      </div>
     <input class=input_btn value="" type=submit src=Inc/global/images/btn_search.gif name=submit style="cursor:hand;" />
    </div>
    <div class=keywords>
      <ul>
        <li class=key1>热门搜索:
        </li>
      </ul>
    </div>
  </form>
</div><div id="mainbody">
<BR>
<TABLE cellSpacing=1 cellPadding=5 width=950 align=center bgColor=#e7e7e7 
border=0>
  <TBODY>
  <TR>
    <TD bgColor=#ffffff colSpan=2>
      <TABLE cellSpacing=0 width=846 border=0>
        <TBODY>
        <TR>
          <TD width=848>您正在上传视频：<strong>第二步 <span class="title"><b>
    <%if action="Add"then%>
添加
<%else%>
修改
<%end if%>
视屏成功</b></strong></td>
        <td width="90"><img src="imgs/upload_help.gif" width="15" height="17"><A href="#">上传帮助</A></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td width="940" height="174"  bgcolor="#F7F7F7"> <table width="918" height="144" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">


  <%if Passed=False then%>
  <%end if%>
  <tr bgcolor="#FFFFFF" class="tdbg"> 
    <td width='250' align="center" valign="top"><img src="<%=PhotoUrl_Thumb%>" width="140"></td>
    <td width="950" valign="top"><table width="100%" border="0" cellpadding="7" cellspacing="1" bgcolor="#CCCCCC">
         <tr bgcolor="#FFFFFF"> 
          <td ><strong>所属类别：</strong></td>
          <td width="580"><%= dvHtmlEncode(classname) %></td>
        </tr>
		<tr bgcolor="#FFFFFF"> 
          <td ><strong>视屏名称：</strong></td>
          <td width="194"><%= dvHtmlEncode(PhotoName) %></td>
        </tr>
        <tr bgcolor="#Fafafa"> 
          <td ><strong>视屏简介：</strong></td>
          <td> <%= dvHtmlEncode(AuthorHomepage) %></td>
        </tr>
    </table></td>
  </tr>
  <tr bgcolor="#FFFFFF" class="tdbg"> 
    <td height="40" colspan="2" align="center">【<a href="upload.asp">继续上传</a>】&nbsp;【<a href="video_play.asp?PhotoID=<%=PhotoID%>"target="_blank">预览视屏</a>】</td>
  </tr>
</table>
</body>
</html>
<%
end sub
%>





</TD></TR></TBODY></TABLE>
<DIV id=foot><BR><BR><BR><BR><BR><BR><!--#include file="end.asp"--></DIV></DIV></BODY></HTML>
