<!--#include file="../../Cache/QvodCms.Admin.asp"-->
<!--#include file="../../Cache/QvodCms.Class.asp"-->
<!--#include file="../../Include/QvodCms.Security.asp"-->
<!--#include file="../../Include/QvodCms.Fun.asp"-->
<!--#include file="../../Include/QvodCms.Fso.asp"-->
<!--#include file="../../Include/QvodCms.XmlHttp.asp"-->
<%
Dim Cai_Msg
'**************************************************
'函数名：InsertData
'作  用：智能检查采集入库
'参  数：Dim 
Sub InsertData(class_id,cj_data_name,cj_data_actor,cj_data_director,cj_data_erea,cj_data_picurl,cj_data_picurll,cj_data_intro,cj_data_reurl,cj_data_playpath,cj_data_playurl)
			
	Set rs = Server.CreateObject("adodb.recordset")
	sql = " Select * from qvodcms_name where data_name='"&cj_data_name&"' "
	rs.Open sql, Conn, 3, 3
	  If Not(rs.bof or rs.eof) Then
			'无来源有同名,编辑影片与地址
			'Response.Write "dddddd"
			'Response.End()
			Call QvodCms_Data_Url(class_id,cj_data_name,cj_data_actor,cj_data_director,cj_data_erea,cj_data_picurl,cj_data_picurll,cj_data_intro,cj_data_reurl,cj_data_playpath,cj_data_playurl,0)
			Response.Write(Cai_Msg)
	  Else
			'无来源无同名,新加影片与地址
			
			Call QvodCms_Data_Url(class_id,cj_data_name,cj_data_actor,cj_data_director,cj_data_erea,cj_data_picurl,cj_data_picurll,cj_data_intro,cj_data_reurl,cj_data_playpath,cj_data_playurl,1)
			Response.Write(Cai_Msg)
	  End If 
    rs.Close:Set rs=Nothing
End Sub

'**************************************************
'函数名：QvodCms_Data_Url
'作  用：智能检查并入库
'参  数：str
Sub QvodCms_Data_Url(class_id,cj_data_name,cj_data_actor,cj_data_director,cj_data_erea,cj_data_picurl,cj_data_picurll,cj_data_intro,cj_data_reurl,cj_data_playpath,cj_data_playurl,str)
   'Response.Write cj_data_playurl
   'Response.End()
    Dim cution:cution=str
    IF cj_data_playpath="" Or cj_data_playurl="" Then
	   Cai_Msg=""&cj_data_name&"&nbsp;<font color='#0000FF'>数据不完整，不进行处理!</font><BR>"
	Else
	     If cution=0 Then'修复地址		 
		     If  Lcase(rs("data_playurl"))=Lcase(cj_data_playurl) And Lcase(rs("data_playpath"))=Lcase(cj_data_playpath) Then
				 Cai_Msg=""&cj_data_name&"&nbsp;<font color='#0000FF'>数据相同，暂不需要更新!</font><BR>"
	         Else
		         IF Instr(rs("data_playpath"),cj_data_playpath)<=0 Then
					cj_data_playpath=rs("data_playpath")&"$$"&cj_data_playpath
					cj_data_playurl=rs("data_playurl")&"$$$"&cj_data_playurl
				 Else
					Dim k
					Dim R_PlayUrl
					Dim Temp_PlayPath:Temp_PlayPath=Split(rs("data_playpath"),"$$")
					Dim Temp_PlayUrl:Temp_PlayUrl=split(rs("data_playurl"),"$$$")
					
					For k=0 To Ubound(Temp_PlayPath)
						IF k<=Ubound(Temp_PlayUrl) Then
						IF Lcase(Temp_PlayPath(k))=Lcase(cj_data_playpath) Then
							Temp_PlayUrl(k)=cj_data_playurl
						End IF
						    R_PlayUrl=R_PlayUrl&Temp_PlayUrl(k)&"$$$"
						End IF
					Next
					IF  Right(R_PlayUrl,3)="$$$" Then R_PlayUrl=Left(R_PlayUrl,Len(R_PlayUrl)-3) End IF
					cj_data_playurl=R_PlayUrl
					cj_data_playpath=rs("data_playpath")
					 R_PlayUrl=""
				 End IF
				    rs("data_lastdate")=Now()
				    rs("data_reurl")=cj_data_reurl
				    rs("data_playpath")=cj_data_playpath
				    rs("data_playurl")=ReplaceCai(cj_data_playurl)
				    rs.update:Response.flush() '输出缓存
				    Cai_Msg=""&cj_data_name&"&nbsp;<font color='#0000FF'>数据发生改变，更新播放地址!</font><BR>"
			   End If
		    Else
				rs.AddNew
	            rs("class_id")=class_id
	            rs("data_name")=cj_data_name
				IF cj_data_actor="" then cj_data_actor="未知" End IF
	            rs("data_actor")=cj_data_actor
	            rs("data_director")=cj_data_director
	            rs("data_erea")=cj_data_erea
	            rs("data_picbig")=cj_data_picurl
		        rs("data_picsmall")=cj_data_picurll
	            rs("data_intro")=cj_data_intro
	            rs("data_lastdate")=Now()
	            rs("data_hits")=10
	            rs("data_status")="1"
	            rs("data_year")=2010
	            rs("data_language")="国语"
				rs("data_reurl")=cj_data_reurl
	            rs("data_Ping")=getpy(Trim(cj_data_name))
	            rs("data_py")=getpyin(Trim(cj_data_name))'汉字拼音转换 
	            rs("data_playpath")=cj_data_playpath
				rs("data_playurl")=ReplaceCai(cj_data_playurl)
				rs.update:Response.flush() '输出缓存
				Cai_Msg="<font color='red'>"&cj_data_name&"&nbsp;无重名，新加影片入库成功!</font><BR>"
		   End If	
	End If   	  
End Sub


Function ReplaceCai(str)
	code_content=Trim(str)
	code_content=replace(code_content,chr(10),"")
	code_content=replace(code_content,chr(13),"")
	code_content=replace(code_content," ","")
	ReplaceCai=code_content
End Function
%>