<!--#include file="admin_conn.asp"-->
<!--#include file="../inc/pinyin.asp"-->
<!--#include file="../inc/config.interface.asp"-->
<%
dim action,pass
action = be("all","action")
pass = be("all","pass")

Select Case action
    Case "retype":  chkLogin : headAdmin "分类转换配置": retype
    Case "retypesave": retypesave
    Case "vod": vod
    Case "art": art
    Case Else: chkLogin :headAdmin "接口配置": main
end select
dispseObj()

Function gettypere(ByVal flag, ByVal tName)
    gettypere = 0
    Dim str, str1, arr1, arr2, arr3, i, j, typearr
    
    If flag = "art" Then
        typearr = cachearttype
        str = getFileByCache("retype_art", "../inc/dim_retype_art.txt")
    Else
        typearr = cachevodtype
        str = getFileByCache("retype_vod", "../inc/dim_retype_vod.txt")
    End If
    
    If Not isN(str) Then
        str = Replace(str, Chr(10), Chr(13))
        arr1 = Split(str, Chr(13))
        
        For i = 0 To UBound(arr1)
            If Not isN(arr1(i)) Then
                str1 = arr1(i)
                arr2 = Split(str1, "=")
                
                If Trim(tName) = Trim(arr2(1)) Then
                    
                    For j = 0 To UBound(typearr)
                        arr3 = typearr(j)
                        
                        If Trim(arr3(1)) = Trim(arr2(0)) Then
                            gettypere = arr3(0)
                            Exit For
                        End If
                    Next
                    
                    Exit For
                End If
                
            End If
        Next
        
    End If
    
End Function

Sub vod()
    Dim d_id, d_name, d_subname, d_enname,d_letter,d_type, d_state, d_color, d_pic, d_starring, d_directed, d_area, d_year, d_language, d_level, d_stint, d_hits, d_dayhits, d_weekhits, d_monthhits, d_topic, d_content, d_remarks, d_hide, d_good, d_bad, d_usergroup, d_score, d_scorecount, d_addtime, d_time, d_hitstime, d_playurl, d_playfrom, d_playserver,d_downurl,d_downfrom,d_downserver, d_picthumb, d_picslide, tmptype, tmptypeid
	Dim resultdes, newplayurl, newplayfrom, newplayserver, oldplayurl, oldplayfrom, oldplayserver, newdownurl, newdownfrom, newdownserver, olddownurl, olddownfrom, olddownserver,playurlarr,playfromarr,playserverarr,downurlarr,downfromarr,downserverarr
	Dim rc,rs,sql,arr1,arr2,arr3,j,k
	
	if app_interfacepass <> pass then writee "非法使用err"
	
    d_id = be("all", "d_id")
    d_name = be("all", "d_name"): d_subname = be("all", "d_subname"): d_enname = be("all", "d_enname"): d_type = be("all", "d_type")
    d_state = be("all", "d_state"): d_color = be("all", "d_color"):  d_starring = be("all", "d_starring"): d_year = be("all", "d_year"): 
    d_directed = be("all", "d_directed"): d_area = be("all", "d_area"): d_language = be("all", "d_language"): d_level = be("all", "d_level")
    d_stint = be("all", "d_stint"): d_hits = be("all", "d_hits"): d_dayhits = be("all", "d_dayhits"): d_weekhits = be("all", "d_weekhits")
    d_monthhits = be("all", "d_monthhits"): d_topic = be("all", "d_topic"): d_content = be("all", "d_content"): d_remarks = be("all", "d_remarks")
    d_hide = be("all", "d_hide"): d_good = be("all", "d_good"):  d_bad = be("all", "d_bad"): d_usergroup = be("all", "d_usergroup")
    d_pic = be("all", "d_pic"): d_picthumb = be("all", "d_picthumb"): d_picslide = be("all", "d_picslide")
    d_playurl = be("all", "d_playurl"): d_playfrom = be("all", "d_playfrom"): d_playserver = be("all", "d_playserver")
    d_downurl = be("all", "d_downurl"): d_downfrom = be("all", "d_downfrom"): d_downserver = be("all", "d_downserver")
    d_addtime = be("all", "d_addtime"): d_time = be("all", "d_time")
    d_addtime = Now
    d_time = Now
    If Not isNum(d_usergroup) Then d_usergroup = 0
    
    If isN(d_name) Then writeA "视频名称不能为空err": Exit Sub
    If isN(d_type) Then writeA "视频分类不能为空err": Exit Sub
    
    If Not isNum(d_level) Then d_level = 0
    If Not isNum(d_hits) Then d_hits = 0
    If Not isNum(d_topic) Then d_topic = 0
    If Not isNum(d_stint) Then d_stint = 0
    If Not isNum(d_state) Then d_state = 0
    If not isNum(d_score) then d_score=0
    if not isNum(d_scorecount) then d_scorecount=0
    If not isNum(d_good) then d_good=0
    If not isNum(d_bad) then d_bad=0
    If not isNum(d_hide) then d_hide = 0
    
    If isN(d_enname) Then d_enname = Hanzi2PinYin(d_name)
    If (InStr(d_enname, "*") Or InStr(d_enname, ":") Or InStr(d_enname, "?") Or InStr(d_enname, """") Or InStr(d_enname, "<") Or InStr(d_enname, ">") Or InStr(d_enname, "|") Or InStr(d_enname, "\")) Then
        writeA "名称和拼音名称中: 不能出现英文输入状态下的 * : ? "" < > | \ 等特殊符号err": Exit Sub
    End If
    d_letter = UCase(left(d_enname,1))
    rc = False
    
    If not isN(d_playurl) then
    	if isN(d_playfrom) Then writeA "视频播放器类型不能为空err": Exit Sub
	    playurlarr = split(d_playurl,"$$$")  : playfromarr = split(d_playfrom,"$$$") : playserverarr = split(d_playserver,"$$$")
	    if ubound(playurlarr) <> ubound(playfromarr) then
	    	writeA "播放器类型、播放地址数量不一致,多组数据请用$$$连接err" : exit sub
	    end if
    end if
    
    If not isN(d_downurl) then
    	if isN(d_downfrom) Then writeA "视频下载类型不能为空err": Exit Sub
	    downurlarr = split(d_downurl,"$$$")  : downfromarr = split(d_downfrom,"$$$") : downserverarr = split(d_downserver,"$$$")
	    if ubound(downurlarr) <> ubound(downfromarr) then
	    	writeA "下载类型、下载地址数量不一致,多组数据请用$$$连接err" : exit sub
	    end if
    end if
    
    tmptype = ""
    tmptypeid = 0
    tmptype = d_type
    If Not isNum(d_type) Then tmptypeid = gettypere("vod", d_type) Else tmptypeid = CInt(d_type)
    If tmptypeid = 0 Then writeA d_name & " " & tmptype & " 没有找到转换的分类err": Exit Sub
    d_type = tmptypeid
    
    If Not isN(d_playurl) Then
        d_playurl = Replace(d_playurl, chr(13), "#")
        d_playurl = Replace(d_playurl, chr(10), "#")
        d_playurl = Replace(d_playurl, "###", "#")
        d_playurl = Replace(d_playurl, "##", "#")
    End If
    
    If Not isN(d_downurl) Then
        d_downurl = Replace(d_downurl, chr(13), "#")
        d_downurl = Replace(d_downurl, chr(10), "#")
        d_downurl = Replace(d_downurl, "###", "#")
        d_downurl = Replace(d_downurl, "##", "#")
    End If
    
    sql = "SELECT * FROM {pre}vod WHERE d_name ='" & d_name & "' "
    Set rs = objdb.DB(sql, "rs3")
    If rs.EOF And rs.Bof Then
        resultdes = "新增数据ok"
        objdb.add "{pre}vod", Array("d_name", "d_subname", "d_enname", "d_type", "d_state","d_letter","d_color", "d_pic","d_picthumb","d_picslide", "d_starring", "d_directed", "d_area", "d_year", "d_language", "d_level", "d_stint", "d_hits", "d_topic", "d_content", "d_remarks", "d_usergroup", "d_score", "d_scorecount","d_good","d_bad", "d_hide","d_addtime", "d_time", "d_playurl","d_playfrom", "d_playserver","d_downurl", "d_downfrom","d_downserver"), Array(d_name, d_subname, d_enname, d_type, d_state,d_letter, d_color, d_pic,d_picthumb,d_picslide, d_starring, d_directed, d_area, d_year, d_language, d_level, d_stint, d_hits, d_topic, d_content, d_remarks, d_usergroup, d_score, d_scorecount,d_good,d_bad,d_hide, d_addtime, d_time, d_playurl, d_playfrom, d_playserver, d_downurl, d_downfrom, d_downserver)
    Else
        If InStr(rs("d_pic"), "http:") > 0 Then rs("d_pic") = d_pic
        If InStr(rs("d_picthumb"), "http:") > 0 Then rs("d_picthumb") = d_picthumb
        If InStr(rs("d_picslide"), "http:") > 0 Then rs("d_picslide") = d_picslide
        
        If not isN(d_playurl) then
	        oldplayurl = rs("d_playurl") : if isN(oldplayurl) then oldplayurl=""
	        oldplayfrom = rs("d_playfrom") : if isN(oldplayfrom) then oldplayfrom=""
	        oldplayserver = rs("d_playserver") : if isN(oldplayserver) then oldplayserver=""
	        newplayurl = ""
	        newplayfrom = ""
	        newplayserver = ""
	        
	        If oldplayurl = d_playurl Then
	            resultdes = "无需更新播放地址ok"
	            newplayurl = oldplayurl
	            newplayfrom = oldplayfrom
	            newplayserver = oldplayserver
	        elseif isN(oldplayfrom) then
	        	resultdes = "新增播放地址ok"
	            newplayurl = oldplayurl
	            newplayfrom = oldplayfrom
	            newplayserver = oldplayserver
	        Else
	            resultdes = "更新播放地址ok"
	            rc = False
	            arr1 = Split(oldplayurl, "$$$")
	            arr2 = Split(oldplayfrom, "$$$")
	            arr3 = split(oldplayserver,"$$$")
	            
				for j=0 to ubound(arr2)
					If rc Then
	            		newplayurl = newplayurl & "$$$"
	            		newplayfrom = newplayfrom & "$$$"
	            		newplayserver = newplayserver & "$$$"
	            	end if
					for k=0 to ubound(playfromarr)
						if arr2(j) = playfromarr(k) then
		            		arr1(j) = playurlarr(k)
		                	exit for
		            	end if
					next
					newplayurl = newplayurl & arr1(j)
		            newplayfrom = newplayfrom & arr2(j)
		            if ubound(arr3) >= j then
		            	newplayserver = newplayserver & arr3(j)
		            else
		            	newplayserver = newplayserver & "0"
		            end if
		            rc=true
				next
				 
	            for k=0 to ubound(playfromarr)
		            for j=0 to ubound(arr2)
		            	if instr(","&oldplayfrom,playfromarr(k) ) <=0 then
		            		newplayfrom = newplayfrom & "$$$" & playfromarr(k)
		            		newplayurl = newplayurl & "$$$" & playurlarr(k)
		            		oldplayfrom = oldplayfrom & "$$$" & playfromarr(k)
		            		if ubound(playserverarr) >= k then
		            			newplayserver = newplayserver & "$$$" & playserverarr(k)
		            		else
		            			newplayserver = newplayserver  & "$$$" & "0"
		            		end if
		            		resultdes = "新增播放地址ok"
		            	end if
		            next
	            next
	            
	            set arr1 =nothing
	            set arr2 =nothing
	            set arr3 =nothing
	        End If
	    end if
	    
	    If not isN(d_downurl) then
	        olddownurl = rs("d_downurl") : if isN(olddownurl) then olddownurl=""
	        olddownfrom = rs("d_downfrom") : if isN(olddownfrom) then olddownfrom=""
	        olddownserver = rs("d_downserver") : if isN(olddownserver) then olddownserver=""
	        newdownurl = ""
	        newdownfrom = ""
	        newdownserver = ""
	        
	        If olddownurl = d_downurl Then
	            resultdes = "无需更新下载地址ok"
	            newdownurl = olddownurl
	            newdownfrom = olddownfrom
	            newdownserver = olddownserver
	        elseif isN(olddownfrom) then
	        	resultdes = "新增下载地址ok"
	            newdownurl = olddownurl
	            newdownfrom = olddownfrom
	            newdownserver = olddownserver
	        Else
	            resultdes = "更新下载地址ok"
	            rc = False
	            arr1 = Split(olddownurl, "$$$")
	            arr2 = Split(olddownfrom, "$$$")
	            arr3 = split(olddownserver,"$$$")
	            
				for j=0 to ubound(arr2)
					If rc Then
	            		newdownurl = newdownurl & "$$$"
	            		newdownfrom = newdownfrom & "$$$"
	            		newdownserver = newdownserver & "$$$"
	            	end if
					for k=0 to ubound(downfromarr)
						if arr2(j) = downfromarr(k) then
		            		arr1(j) = downurlarr(k)
		                	exit for
		            	end if
					next
					newdownurl = newdownurl & arr1(j)
		            newdownfrom = newdownfrom & arr2(j)
		            if ubound(arr3) >= j then
		            	newdownserver = newdownserver & arr3(j)
		            else
		            	newdownserver = newdownserver & "0"
		            end if
		            rc=true
				next
				 
	            for k=0 to ubound(downfromarr)
		            for j=0 to ubound(arr2)
		            	if instr(","&olddownfrom,downfromarr(k) ) <=0 then
		            		newdownfrom = newdownfrom & "$$$" & downfromarr(k)
		            		newdownurl = newdownurl & "$$$" & downurlarr(k)
		            		olddownfrom = olddownfrom & "$$$" & downfromarr(k)
		            		if ubound(downserverarr) >= k then
		            			newdownserver = newdownserver & "$$$" & downserverarr(k)
		            		else
		            			newdownserver = newdownserver  & "$$$" & "0"
		            		end if
		            		resultdes = "新增下载地址ok"
		            	end if
		            next
	            next
	            
	            set arr1 =nothing
	            set arr2 =nothing
	            set arr3 =nothing
	        End If
	    end if
	    
        rs("d_remarks") = d_remarks
        rs("d_state") = d_state
        rs("d_time") = Now()
        rs("d_playurl") = newplayurl
        rs("d_playfrom") = newplayfrom
        rs("d_playserver") = newplayserver
        rs("d_downurl") = newdownurl
        rs("d_downfrom") = newdownfrom
        rs("d_downserver") = newdownserver
        rs.update
    End If
    set playfromarr = nothing
    set playurlarr = nothing
    set playserverarr = nothing
    set downfromarr = nothing
    set downurlarr = nothing
    set downserverarr = nothing
    
    objdb.C (rs)
    writeA resultdes
    Exit Sub
End Sub


Sub art()
    Dim a_id, a_title, a_subtitle, a_entitle, a_letter,a_type, a_content, a_author, a_color, a_from,a_hits, a_dayhits, a_weekhits, a_monthhits, a_hide, a_addtime, a_time, a_hitstime,a_pic, rs
    if app_interfacepass <> pass then writee "非法使用err"
    
    a_id = be("all", "a_id"): a_title = be("all", "a_title"): a_subtitle = be("all", "a_subtitle"): a_entitle = be("all", "a_entitle")
    a_type = be("all", "a_type"): a_content = be("all", "a_content"): a_author = be("all", "a_author"): a_color = be("all", "a_color")
    a_hits = be("all", "a_hits"): a_dayhits = be("all", "a_dayhits"): a_weekhits = be("all", "a_weekhits"): a_monthhits = be("all", "a_monthhits")
    a_from = be("all", "a_from"): a_pic = be("all", "a_pic")
    a_hide = be("all", "a_hide"): a_addtime = be("all", "a_addtime"): a_time = be("all", "a_time"): a_hitstime = be("all", "a_hitstime")
    
    a_addtime = Now
    a_time = Now
    If isN(a_title) Then writeA "文章标题不能为空err": Exit Sub
    If isN(a_type) Then writeA "文章分类不能为空err": Exit Sub
    If Not isNum(a_hits) Then a_hits = 0
    If Not isNum(a_hide) Then a_hide = 0
    If isN(a_entitle) Then a_entitle = Hanzi2PinYin(a_title)
    
    If (InStr(a_entitle, "*") Or InStr(a_entitle, ":") Or InStr(a_entitle, "?") Or InStr(a_entitle, """") Or InStr(a_entitle, "<") Or InStr(a_entitle, ">") Or InStr(a_entitle, "|") Or InStr(a_entitle, "\")) Then
        writeA "名称和拼音名称中: 不能出现英文输入状态下的 * : ? "" < > | \ 等特殊符号err": Exit Sub
    End If
    a_letter = UCase(left(a_entitle,1))
    If Not isNum(a_type) Then a_type = gettypere("art", a_type)
    If a_type = 0 Then writeA "没有找到转换的分类err": Exit Sub
    
    Dim sql: sql = "SELECT * FROM {pre}art WHERE a_title ='" & a_title & "' "
    Set rs = objdb.DB(sql, "rs3")
    If rs.EOF And rs.Bof Then
        objdb.add "{pre}art", Array("a_title", "a_subtitle", "a_entitle", "a_type","a_letter" ,"a_content", "a_author", "a_color", "a_from","a_pic" ,"a_hits","a_hide" , "a_addtime", "a_time"), Array(a_title, a_subtitle, a_entitle, a_type, a_letter,a_content, a_author, a_color, a_from,a_pic , a_hits,a_hide, a_addtime, a_time)
    Else
        rs("a_content") = a_content
    End If
    objdb.C (rs)
    writeA "ok"
End Sub

Sub retypesave()
    Dim vodtype: vodtype = be("post", "vodtype")
    Dim arttype: arttype = be("post", "arttype")
    Dim oldpass: oldpass = be("post", "oldpass")
    Dim temppass: temppass = be("post", "temppass")
    objFile.createFile "../inc/dim_retype_vod.txt", vodtype
    objFile.createFile "../inc/dim_retype_art.txt", arttype
    
    dim str
    str = "<" & "%" & vbcrlf
    str = str & "dim app_interfacepass" & vbcrlf
    str = str & "app_interfacepass=" & chr(34) & trim(request("app_interfacepass")) & chr(34) & "      '站外入库安全验证密码" & vbcrlf
    str = str & "%" & ">"
	objFile.createFile "../inc/config.interface.asp",str
    
    showMsg "修改完毕", "admin_interface.asp?action=retype"
End Sub

Sub retype()
%>
<form action="?action=retypesave" method="post">
<table class="tb">
<tr class="thead"><th colspan="2">此功能主要用于第三方工具（火车头、ET等）入库接口转换。>>> 1.每个各占一行; 2.本地分类在前,采集分类在后(动作片=动作).;3.不要有多余的空行</th></tr>
<tr><td width="50%">视频分类转换</td>
<td width="50%">文章分类转换</td>
</tr>
<tr>
    <td>
    <textarea id="vodtype" name="vodtype" style="width:100%;font-family: Arial, Helvetica, sans-serif;font-size: 14px;" rows="25"><%=objFile.getFile("../inc/dim_retype_vod.txt")%></textarea>
    </td>
    <td>
    <textarea id="arttype" name="arttype" style="width:100%;font-family: Arial, Helvetica, sans-serif;font-size: 14px;" rows="25"><%=objFile.getFile("../inc/dim_retype_art.txt")%></textarea>
    </td>
    </tr>
    <tr>
    <td align="center" colspan="2">入库免登录安全验证密码:<input id="app_interfacepass" name="app_interfacepass" size="20" value="<%=app_interfacepass%>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" id="btnSave" name="btnSave" value="保存" class="input" /> </td>
    </tr>
</table>
</form>
</body>
</html>
<%
End Sub

Sub main()
    
End Sub
%>