<!--#include file="../inc/MainClass.asp"-->
<%
'******************************************************************************************
' Software name: Max(马克斯) Content Management System
' Version:4.0
' Web: http://www.maxcms.net
' Author: 石头(maxcms2008@qq.com),yuet,长明,酒瓶
' Copyright (C) 2005-2014 马克斯官方 版权所有
' 法律申明：MaxCMS程序所有代码100%原创、未引入任何网上代码,对一切抄袭行为、坚决严肃追究法律责任
'******************************************************************************************
Response.Addheader "Content-Type","text/html; charset=gbk"
dim updateUrl,versionXml
updateUrl = "h"&"ttp"&"://ma"&"xcms.bo"&"kec"&"c.com/update/max4.0"
versionXml ="ht"&"tp://maxc"&"ms.bok"&"ecc.com/update/max4.0/maxcmsver4.0.xml"
const selfMenuXml ="imgs/selfmenu.xml"
const customMenuXml ="imgs/custommenu.xml"
dim menuList : menuList = getBigMenuInfo(0)


Sub viewFoot
	echo "<div align=center>"
	echoRunTime
	terminateAllObjects
	echo "</div><div align=center >Copyright 2005-2014 All rights reserved. <a target=""_blank"" href=""http://www.maxcms.net"">Maxcms4.0</a></div>" & chr(10) & "</body>" & chr(10) & "</html>"
End Sub

Sub viewHead(str)
	checkPower:session("loginflag")=gbookuser&gbookpwd
%><!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">
<head>
<meta http-equiv="content-type" content="text/html; charset=gbk" />
<meta name="robots" content="noindex,nofollow" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<TITLE><%=str%>-MaxCMS后台管理</TITLE>
<link href="imgs/admin.css" rel="stylesheet" type="text/css" />
<script src="../js/common.js" type="text/javascript"></script>
<script src="imgs/main.js" type="text/javascript"></script>
<style type="text/css">
.btn{border:1px solid;border-color:#fff #999 #999 #fff;}
</style>
</head>
<body>
<%
End Sub

Function getBigMenuInfo(level)
	redim bigMenu(0,0)
	select case clng(level)
		case 0
			redim bigMenu(8,2)
			bigMenu(0,0)="首页" : bigMenu(0,1)="common" : bigMenu(0,2)="index.asp?action=notice"
			bigMenu(1,0)="数据" : bigMenu(1,1)="content" : bigMenu(1,2)="admin_video.asp?action=else"
			bigMenu(2,0)="模板" : bigMenu(2,1)="template" : bigMenu(2,2)="admin_template.asp?action=main"
			bigMenu(3,0)="生成" : bigMenu(3,1)="make" : bigMenu(3,2)="admin_makehtml.asp?action=main"
			bigMenu(4,0)="工具" : bigMenu(4,1)="tool" : bigMenu(4,2)="admin_datarelate.asp?action=repeat"
			bigMenu(5,0)="广告" : bigMenu(5,1)="ads" : bigMenu(5,2)="admin_ads.asp?action=main"
			bigMenu(6,0)="采集" : bigMenu(6,1)="gathersoft" : bigMenu(6,2)="admin_collect.asp?action=main"
			bigMenu(7,0)="扩展" : bigMenu(7,1)="webhelper" : bigMenu(7,2)="admin_gbook.asp?action=comment&where=gbook"
			bigMenu(8,0)="系统" : bigMenu(8,1)="system" : bigMenu(8,2)="admin_config.asp"
		case 1
			redim  bigMenu(0,2)
			bigMenu(0,0)="数据管理" : bigMenu(0,1)="common" : bigMenu(0,2)="admin_video.asp?action=else"
	end select
	getBigMenuInfo = bigMenu
End Function

Function getSmallMenuInfo(level)
	redim smallMenu(0)
	select case clng(level)
		case 0
			redim  smallMenu(8)
			smallMenu(0)="后台首页,index.asp?action=notice|快捷菜单,admin_selfmenu.asp|"&getSelfMenu(0)
			smallMenu(1)="临时表管理,admin_tempvideo.asp||分类管理,admin_type.asp|数据管理,admin_video.asp?action=else|添加数据,admin_video.asp?action=add|连载数据,admin_video.asp?m_state=ok|推荐数据,admin_video.asp?m_commend=ok|数据回收站,admin_video.asp?action=recycle|专题管理,admin_topic.asp|报错数据,admin_gbook.asp?action=reporterror&where=reporterror|伪原创设置,admin_pseudo.asp||新闻分类,admin_newstype.asp|新闻管理,admin_news.asp|新闻添加,admin_news.asp?action=add|新闻回收站,admin_news.asp?action=recycle"
			smallMenu(2)="模板管理,admin_template.asp?action=main|管理自定义模板,admin_template.asp?action=custom||自定义标签,admin_selflabel.asp||标签向导,admin_labelguide.asp"
			smallMenu(3)="生成选项,admin_makehtml.asp?action=main||生成百度地图,admin_makehtml.asp?action=baidu|生成谷歌地图,admin_makehtml.asp?action=google|生成RSS,admin_makehtml.asp?action=rss"
			smallMenu(4)="重复数据检测,admin_datarelate.asp?action=repeat|数据批量替换,admin_datarelate.asp?action=batch|删除指定来源,admin_datarelate.asp?action=delvideoform|修复数据格式,admin_datarelate.asp?action=repairplaydata|批量设置点击量,admin_datarelate.asp?action=randomset||无效图片清除,admin_datarelate.asp?action=checkpic||内存溢出处理,admin_datarelate.asp?action=japan||SQL高级助手,admin_datarelate.asp?action=sql||数据库备份、压缩,admin_database.asp"
			smallMenu(5)="广告管理,admin_ads.asp?action=main|添加广告,admin_ads.asp?action=add||友情链接,admin_link.asp"
			smallMenu(6)="视频项目列表,admin_collect.asp?action=main|添加视频项目,admin_collect.asp?action=wizard|视频分类转换,admin_collect.asp?action=customercls|视频信息过滤,admin_collect.asp?action=filters|视频采集数据库,admin_collect.asp?action=tempdatabase||新闻项目列表,admin_collectnews.asp?action=main|添加新闻项目,admin_collectnews.asp?action=wizard|新闻分类转换,admin_collectnews.asp?action=customercls|新闻信息过滤,admin_collectnews.asp?action=filters|新闻采集数据库,admin_collectnews.asp?action=tempdatabase"

			smallMenu(7)="留言管理,admin_gbook.asp?action=comment&where=gbook|回复留言,../gbook.asp|视频评论管理,admin_comment.asp?action=comment&where=1|新闻评论管理,admin_comment.asp?action=comment&where=2|幻灯片管理,admin_expand.asp||马克斯盒子,admin_boxad.asp||标签文档手册,http://bbs.bokecc.com/viewthread.php?tid=98050|模板下载,http://bbs.bokecc.com/forumdisplay.php?fid=97|教程学习,http://bbs.bokecc.com/forumdisplay.php?fid=105"
			smallMenu(8)="网站配置,admin_config.asp||播放器设置,admin_player.asp|播放来源管理,admin_player.asp?action=boardsource||系统账号管理,admin_manager.asp"
		case 1
			redim  smallMenu(0)
			smallMenu(0)="后台首页,index.asp?action=notice|快捷菜单,admin_selfmenu.asp|数据管理,admin_video.asp?action=else|添加数据,admin_video.asp?action=add|生成选项,admin_makehtml.asp?action=main|"&getSelfMenu(1)
	end select
	getSmallMenuInfo = smallMenu
End Function

Function getSelfMenu(level)
	dim xmlobj,selfMenuListNode,menuNodes,menuNodesLen,i,menuName,menuLink,menuStr,path:path=selfMenuXml
	set xmlobj = mainClassobj.createObject("MainClass.Xml")
	if level=1 then:path=customMenuXml:end if
	xmlobj.load path,"xmlfile"
	set selfMenuListNode=xmlobj.getNodes("maxcms2/menulist")(0)
	set menuNodes=selfMenuListNode.selectNodes("menu") : menuNodesLen=menuNodes.length
	for i=0 to menuNodesLen-1
		menuName=menuNodes(i).selectNodes("name")(0).text : menuLink=menuNodes(i).selectNodes("link")(0).text
		if not isNul(menuName) and not isNul(menuLink) then 
			if i<menuNodesLen-1  then menuStr=menuStr&menuName&","&menuLink&"|" else menuStr=menuStr&menuName&","&menuLink
		else
			if i<menuNodesLen-1  then menuStr=menuStr&"|" else menuStr=menuStr
		end if
	next
	set menuNodes=nothing : set selfMenuListNode=nothing : set xmlobj=nothing
	if not isNul(menuStr) then getSelfMenu="|"&menuStr
End Function

Function selfManageDir()
	dim dir
	if Request.ServerVariables("SERVER_PORT")<>"80" then
    	dir = "http://"&Request.ServerVariables("SERVER_NAME")& ":" & Request.ServerVariables("SERVER_PORT")& Request.ServerVariables("URL")
    else
    	dir = "http://"&Request.ServerVariables("SERVER_NAME")& Request.ServerVariables("URL")
	end if
	dir=left(dir,InstrRev(dir,"/")-1)
	dir=mid(dir,InstrRev(dir,"/")+1)&"/"
	selfManageDir=dir
End Function

Sub checkPower
	dim loginValidate,rsObj : loginValidate = "maxcms"
	err.clear
	on error resume next
	set rsObj=conn.db("select m_random,m_level from {pre}manager where m_username='"&replaceStr(rCookie("m_username"),"'","")&"'","execute")
	loginValidate = md5(getAgent&getIp&rsObj(0),32)
	if err then clearPower : die ""
	if rCookie("check"&rCookie("m_username"))<>loginValidate then clearPower : die ""
	checkManagerLevel rsObj(1)
	rsObj.close:set rsObj=nothing
End Sub

Sub checkManagerLevel(level)
	dim curUrl : curUrl=request.ServerVariables("URL")
	if instr(curUrl,"admin_video.asp")=0 and instr(curUrl,"index.asp")=0 and instr(curUrl,"admin_ajax.asp")=0 and instr(curUrl,"admin_webgather.asp")=0 and instr(curUrl,"maxcms_upload.asp")=0  and instr(curUrl,"m_ax_cm_s_fck_upload.asp")=0 and instr(curUrl,"admin_makehtml.asp")=0 and instr(curUrl,"admin_selfmenu.asp")=0 then
		if clng(level)<>0 then  alertMsg "没有权限","" : die "<script>top.location.href='index.asp';</script>"
	end if 
End Sub

Sub clearPower
	wCookie "check"&rCookie("m_username"),""
	wCookie "m_username",""
	wCookie "m_id",""
	wCookie "m_level",""
	session("loginflag")=""
	echo "<script>top.location.href='index.asp?action=login';</script>"
End Sub

Function checkField(fieldName,tableName)
	dim flag,sql,rsObj,i : flag=False : sql="select * from "&tableName 
	set rsObj=conn.db(sql,"execute")
	for i = 0 to rsObj.Fields.Count - 1
		if rsObj.Fields(i).Name=fieldName then
			flag=True : Exit For
		else
			flag=False
		end if
	next
	checkField=flag
End Function

Function gatherIntoLibTransfer(Byval data,Byval str,Byval typeset)
	dim transtr,str1,str2,str1Array,str2Array,m,n,j,k,x:str1=data:str2=str
	if  not isNul(str1) and not isNul(str2) then
		select case typeset
			case 0'智能覆盖
				str1Array=split(str1,"$$$"):str2Array=split(str2,"$$$"):m=ubound(str1Array):n=ubound(str2Array)
				for k=0 to n
					x=findIsExistFrom(str1Array,split(str2Array(k),"$$")(0))
					if isNum(x) then 
						str1Array(x)=str2Array(k)
					else
						transtr=transtr&str2Array(k)&"$$$"
					end if
				next
				for j=0 to m
					transtr=transtr&str1Array(j)&"$$$"
				next
				transtr = trimOuterStr(transtr,"$$$")
			case 1'追加为第一个来源
				transtr=str&"$$$"&data
			case 2'追加为最后一个来源
				transtr=data&"$$$"&str
			case 3'完全覆盖
				transtr=str
		end select
	elseif  not isNul(str1) and isNul(str2) then 
		transtr=str1
	elseif isNul(str1) and not isNul(str2) then 
		transtr=str2
	end if
	gatherIntoLibTransfer=transtr
End Function

Function findIsExistFrom(array1,from)
	dim i,m:m=ubound(array1):findIsExistFrom=""
	for i=0 to m
		if trim(split(array1(i),"$$")(0))=trim(from) then
			findIsExistFrom=i:Exit Function		
		end if
	next
End Function

Function getReferedId(str)
	getReferedId = ""
	if instr(str,"土豆高清")>0 then getReferedId = "hd_tudou": exit function
	if instr(str,"新浪高清")>0 then getReferedId = "hd_iask": exit function
	if instr(str,"搜狐高清")>0 then getReferedId = "hd_sohu": exit function
	if instr(str,"天线高清")>0 then getReferedId = "hd_openv": exit function
	if instr(str,"56高清")>0 then getReferedId = "hd_56": exit function
	if instr(str,"56")>0 then getReferedId = "56": exit function
	if instr(str,"优酷")>0 then getReferedId = "youku": exit function
	if instr(str,"土豆")>0 then getReferedId = "tudou": exit function
	if instr(str,"搜狐")>0 then getReferedId = "sohu": exit function
	if instr(str,"新浪")>0 then getReferedId = "iask": exit function
	if instr(str,"六间房")>0 then getReferedId = "6rooms": exit function
	if instr(str,"qq")>0 then getReferedId = "qq": exit function
	if instr(str,"风行")>0 then getReferedId = "funshion": exit function
	if instr(str,"华数视频")>0 then getReferedId = "wasu": exit function
	if instr(str,"激动网")>0 then getReferedId = "joy": exit function
	if instr(str,"m1905")>0 then getReferedId = "m1905": exit function
	if instr(str,"youtube")>0 then getReferedId = "youtube": exit function
	if instr(str,"17173")>0 then getReferedId = "17173": exit function
	if instr(str,"ku6视频")>0 then getReferedId = "ku6": exit function
	if instr(str,"FLV")>0 then getReferedId = "flv": exit function
	if instr(str,"SWF")>0 then getReferedId = "swf": exit function
	if instr(str,"real")>0 then getReferedId = "real": exit function
	if instr(str,"media")>0 then getReferedId = "media": exit function
	if instr(str,"qvod")>0 then getReferedId = "qvod": exit function
	if instr(str,"PPS")>0 then getReferedId = "pps": exit function
	if instr(str,"迅播高清")>0 then getReferedId = "gvod": exit function
	if instr(str,"远古高清")>0 then getReferedId = "wp2008": exit function
	if instr(str,"xigua")>0 then getReferedId = "xigua": exit function
	if instr(str,"闪播Pvod")>0 then getReferedId = "pvod": exit function
	if instr(str,"播客CC")>0 then getReferedId = "cc": exit function
	if instr(str,"吉吉影音")>0 then getReferedId = "jjvod": exit function
	if instr(str,"pptv")>0 then getReferedId = "pptv": exit function
	if instr(str,"奇艺")>0 then getReferedId = "qiyi": exit function
	if instr(str,"百度影音")>0 then getReferedId = "bdhd": exit function
	if instr(str,"乐视")>0 then getReferedId = "letv": exit function
    if instr(str,"cntv")>0 then getReferedId = "cntv": exit function
	if instr(str,"影音先锋")>0 then getReferedId = "xfplay": exit function
	if instr(str,"xfplay")>0 then getReferedId = "xfplay": exit function
	if instr(str,"吉吉影音")>0 then getReferedId = "jjvod": exit function
	if instr(str,"jjvod")>0 then getReferedId = "jjvod": exit function
	if instr(str,"ckplayer")>0 then getReferedId = "ckplayer": exit function
End Function

Function downSinglePic(picUrl,vid,vname,filePath,infotype)
	dim streamLen,spanstr,fileext
	if infotype="" then spanstr="" else spanstr="<br/>"
	on error resume next
	if isNul(picUrl) or instr(picUrl,"http://")=0 then echo "数据<font color=red>"&vname&"</font>的图片路径错误1,请检查是否有效  "&spanstr : downSinglePic=false :Exit Function
	fileext=getFileFormat(filePath)
	if fileext="" then:fileext=".jpg":filePath=filePath&fileext:end if
	if fileext<>"" AND InStr("|.jpg|.gif|.png|.bmp|.jpeg|",LCase(fileext))>0 then
		dim imgStream : imgStream=getRemoteContent(picUrl,"body")
		dim createStreamFileFlag:createStreamFileFlag=createStreamFile(imgStream,filePath)
		if err or createStreamFileFlag=false then 
			if isNul(vid) then
				echo "数据<font color=red>"&vname&"</font>的图片下载发生错误3,请检查是否有效  "&spanstr:err.clear : downSinglePic=false
			else
				echo "数据<font color=red>"&vname&"</font>的图片下载发生错误4,id为<font color=red>"&vid&"</font>,请检查是否有效  "&spanstr: err.clear : downSinglePic=false
			end if
		else
			streamLen=lenB(imgStream)
			if streamLen<1024*2 then
				echo "数据<font color=red>"&vname&"</font>的图片下载发生错误5,请检查是否有效  "&spanstr:err.clear:downSinglePic=false
			else
				echo "数据<font color=red>"&vname&"</font>的图片下载成功,大小为<font color=red>"&formatnumber(streamLen/1024,2)&"</font>KB <a target=_blank href="&filePath&">预览图片</a>  "&spanstr:downSinglePic=true
			end if
		end if
	else
			echo "数据<font color=red>"&vname&"</font>的图片下载发生错误6,图片格式不对  "&spanstr:err.clear:downSinglePic=false
	end if
End Function

Sub makeTypeOptionSelected(topId,separateStr,compareValue)
	Dim i,j,k,m,TL,selectedStr:TL=getTypeLists():j=getTypeindex("m_id"):k=getTypeindex("m_upid"):m=getTypeindex("m_name")
	for i=0 to UBound(TL,2)
		if ""&TL(k,i)=""&topId then
			if clng(topId)<>0 then span=span&separateStr
			if compareValue=TL(j,i) then selectedStr=" selected" else selectedStr=""
			echo "<option value='"&TL(j,i)&"' "&selectedStr&">"&span&"&nbsp;|—"&TL(m,i)&"</option>"
			makeTypeOptionSelected TL(j,i),separateStr,compareValue
		end if
	next
	if not isNul(span) then span = left(span,len(span)-len(separateStr))
End Sub

Sub makeNewsTypeOptionSelected(topId,separateStr,compareValue)
	Dim i,j,k,m,TL,selectedStr:TL=getNewsTypeLists():j=getTypeindex("m_id"):k=getTypeindex("m_upid"):m=getTypeindex("m_name")
	for i=0 to UBound(TL,2)
		if ""&TL(k,i)=""&topId then
			if clng(topId)<>0 then span=span&separateStr
			if compareValue=TL(j,i) then selectedStr=" selected" else selectedStr=""
			echo "<option value='"&TL(j,i)&"' "&selectedStr&">"&span&"&nbsp;|—"&TL(m,i)&"</option>"
			makeNewsTypeOptionSelected TL(j,i),separateStr,compareValue
		end if
	next
	if not isNul(span) then span = left(span,len(span)-len(separateStr))
End Sub

Function timeToStr(Byval t)
	t=Replace(Replace(Replace(Replace(t,"-",""),":","")," ",""),"/","") : timeToStr=t
End Function

Sub isCurrentDay(timeStr)
	if isNul(timeStr) then echo "":Exit Sub
	dim timeStr2 : timeStr2=date
	if instr(timeStr,timeStr2)>0 then  echo "<span style='color:red;font-size:10px'>"&timeStr&"</span>" else echo "<span style='font-size:10px'>"&timeStr&"</span>"
End Sub
%>