<% 
Dim Fy_Url,Fy_a,Fy_x,Fy_Cs(),Fy_Cl,Fy_Ts,Fy_Zx 
'---定义部份 头------ 
Fy_Cl = 1 '处理方式：1=提示信息,2=转向页面,3=先提示再转向 
Fy_Zx = "index.Asp" '出错时转向的页面 
'---定义部份 尾------ 

'on error resume next 
Fy_Url=Request.ServerVariables("QUERY_STRING") 
Fy_a=split(Fy_Url,"&") 
redim Fy_Cs(ubound(Fy_a)) 
'on error resume next 
for Fy_x=0 to ubound(Fy_a) 
Fy_Cs(Fy_x) = left(Fy_a(Fy_x),instr(Fy_a(Fy_x),"=")-1) 
Next 
For Fy_x=0 to ubound(Fy_Cs) 
If Fy_Cs(Fy_x)<>"" Then 
If Instr(LCase(Request(Fy_Cs(Fy_x))),"'")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"select")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"update")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"chr")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"delete%20from")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),";")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"insert")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"mid")<>0 Or Instr(LCase(Request(Fy_Cs(Fy_x))),"master.")<>0 Then 
Select Case Fy_Cl 
Case "1" 
Response.Write "<Script Language=JavaScript>alert(' 出现错误！参数 "&Fy_Cs(Fy_x)&" 的值中包含非法字符串！\n\n 请不要在参数中出现：and,select,update,insert,delete,chr 等非法字符！\n\n我已经设置了不能SQL注入，请不要对我进行非法手段！');window.close();</Script>" 
Case "2" 
Response.Write "<Script Language=JavaScript>location.href='"&Fy_Zx&"'</Script>" 
Case "3" 
Response.Write "<Script Language=JavaScript>alert(' 出现错误！参数 "&Fy_Cs(Fy_x)&"的值中包含非法字符串！\n\n 请不要在参数中出现：,and,select,update,insert,delete,chr 等非法字符！\n\n设计了门，非法侵入请离开，谢谢！');location.href='"&Fy_Zx&"';</Script>" 
End Select 
Response.End 
End If 
End If 
Next 
%>


<%
Server.ScriptTimeOut=5000
%>
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/safe.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="inc/const.asp"-->
<%
if MemberName="" then
  response.Redirect("userlogin.asp")
  response.end
end if
%>
<%
Function ConverFlv(Mname,Fname,Pname)
  dim str,str1,str2  
  str=server.mappath("ffmpeg.exe")
  video=server.mappath("video/"&Mname&"")
  simg=server.mappath("videoimage/"&Pname&"")
  flv=server.mappath("video/"&Fname&"")
  nn=server.mappath("mencoder.exe")

  Set WshShell = server.CreateObject("Wscript.Shell")
 	
  str1= nn&" "& video &" -ffourcc FLV1 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -of lavf -oac mp3lame -lameopts aq=9:cbr:br=64:vol=2 -ovc lavc -lavcopts vcodec=flv:acodec=mp3:abitrate=56 -vf scale=320:240,expand=320:240:::1,crop=320:270:0:0 -ofps 18 -srate 22050 -o "& flv
 
 IsSuccess = WshShell.Run(str1,1,true) 

if IsSuccess = 0 Then
  str2=str&" -i "&flv&" -y -f image2 -t 0.005 -s 120x90 "&simg  
  Isffmpeg = WshShell.Run(str2,1,truE) 
end if
Set WshShell = Nothing 

End Function

dim errmsg
errmsg=""
''on error resume next

  movie=session("upfiname")
  flvname=getfilename(now()) & ".flv"  
  picname=getfilename(now()) & ".jpg"  
  
  ConverFlv movie,flvname,picname

dim title,content,pindao,tag

title=trim(ReplaceBadChar(request.Form("title")))
content=convert(request.Form("description"))
pindao=request.Form("pindao")
tag=request.Form("tags")

if title="" then errmsg=errmsg+"<br>"+"<li>视频的标题不能为空！"
if invalidch(title) or instr(title,"，")>0  then errmsg=errmsg+"<br>"+"<li>您的标题可能含特殊符号，请检查！"
if len(content)>600 then errmsg=errmsg+"<br><li>视频内容简介不能超过600字！"

if errmsg<>"" then 
 response.Write "<table width=400 align=center><tr><td height=25 style='font-size:12px'>错误信息：</td></tr>"
 response.write("<tr><td style='font-size:12px'>"+ errmsg +"<br></td></tr>")
 response.Write "<tr><td align='center'><input type='button' value='返回修改' onClick='javascript:window.history.back();'>"
 response.Write "<input type='button' value='关闭窗口' onClick='javascript:window.close();'></td></tr></table>"
 response.end
end if

set rst=server.CreateObject("adodb.recordset")   
sql1="select * from video_info where id is null"
rst.open sql1,conn,1,3
rst.addnew
rst("userid")=userid
rst("classid")=pindao
rst("username")=membername
rst("tag")=tag
rst("title")=title
rst("content")=content
rst("movie")=flvname
rst("pic")=picname
rst("dtime")=now()
rst("click")=0
rst("score")=0
rst("people")=0
rst.update
rst.close
set rst=nothing

conn.close
set conn=nothing

Set fdel = CreateObject("Scripting.FileSystemObject")	
  filedir=server.MapPath("video/"&movie)  
  If (fdel.FileExists(filedir)) Then
         fdel.DeleteFile(filedir)
  end if                              
Set fdel=nothing		

session("upfiname")=""
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>视频添加成功</title>
<link href="style.css" rel="stylesheet" type="text/css">
<meta HTTP-EQUIV=refresh Content='1;url=selvideo.asp'>
</head>
<table border="0" cellspacing="0" width="100%" cellpadding="0" height="418" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td width="100%" height="418" valign="middle" align="center" class="STYLE4">
<b>您所添加的视频文件信息已经提交发送！<a href="selvideo.asp"><font color="#996633">返回</font></a></b></td>
</tr>
</table>
</body>
</html> 
