<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<%
if session("admin")="" then
  response.redirect "admin_login.asp"
end if

dim action
dim totalpage,maxperpage,totalrecords,i,currentpage
action=request("action")
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Flash管理相关</title>
<script language=javascript src="mouse_up.js"></script>
<link href="admin.css" rel="stylesheet" type="text/css">
</head>

<body leftmargin="0" topmargin="0">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#000000" vspace="0" hspace="0">
  <tr bgcolor="#EFEBEF"> 
    <td height="27"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="86%"><font color="#FF3000">.:: 您可以在这里进行[Flash管理]相关操作</font></td>
          <td width="14%" height="20" align="center"><a href="javascript:this.location.reload()"><img src="images/refresh.gif" alt="刷新" width="40" height="12" border="0"></a></td>
        </tr>
      </table></td>
  </tr>
  <tr > 
    <td height="1" bgcolor="#000000"></td>
  </tr>
</table>
<%
select case action
  case "add"
    call add() 
  case "addsave"
    call addsave()
  case else
    call main()
end select

sub add()
 
'01 Flash添加
if not checkflag("01") then
  call mb("对不起，您没有Flash添加的权限！","",0)
end if


set rs=conn.execute("select * from smallclass")
%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
        <%
		dim count:count = 0
        do while not rs.eof 
        %>
subcat[<%=count%>] = new Array("<%= trim(rs("smallclassname"))%>","<%= trim(rs("bigclassid"))%>","<%= trim(rs("smallclassid"))%>");
        <%
        count = count + 1
        rs.movenext
        loop
        rs.close
        set rs=nothing
        %>
onecount=<%=count%>;

function changelocation(bigclassid)
    {
    document.add.smallclassid.length = 0; 

    var bigclassid=bigclassid;
    var i;
    document.add.smallclassid.options[0] = new Option('请选择二级分类','');
    for (i=0;i < onecount; i++)
        {
            if (subcat[i][1] == bigclassid)
            { 
                document.add.smallclassid.options[document.add.smallclassid.length] = new Option(subcat[i][0], subcat[i][2]);
            }        
        }
        
    }    
</script>
<br>
<form action="?action=addsave" method="post" name="add" id="add">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr align="center" bgcolor="#EFEBEF"> 
      <td height="25" colspan="2"><font color="#000000">添 加 Flash</font></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="20%" height="25" align="center">选择分类：</td>
      <td width="80%" height="25">&nbsp;一级： 
        <select name="bigclassid" size="1" class="input" id="bigclassid" onChange="changelocation(document.add.bigclassid.options[document.add.bigclassid.selectedIndex].value)">
          <option value='' selected>请选择一级分类</option>
          <%set rs=conn.execute("select bigclassid,bigclassname from bigclass order by bigclassid")
					 do until rs.eof
					   response.write "<option value='"&rs(0)&"'>"&rs(1)&"</option>"
					 rs.movenext
					 loop
					 rs.close
					 %>
        </select>
        　二级： 
        <select name="smallclassid" size="1" class="input" id="smallclassid">
          <option value='' selected>请选择二级分类</option>
        </select></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" align="center">Flash名称：</td>
      <td height="25">&nbsp; 
        <input name="flashname" type="text" class="input" id="flashname" size="40"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" align="center">观看地址一：</td>
      <td height="25"> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td height="25">&nbsp;
              <iframe name=ad frameborder=0 width=100% height=30 scrolling=no src=admin_upload.asp?fpath=upload></iframe></td>
          </tr>
          <tr> 
            <td height="25">&nbsp;
              <input name="url" type="text" class="input" id="url3" size="40">
              *.swf *.fla</td>
          </tr>
        </table></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" align="center">观看地址二：</td>
      <td height="25">&nbsp; 
        <input name="url2" type="text" class="input" id="url2" size="40"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" align="center">缩略图地址：</td>
      <td height="25"> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td height="25">&nbsp;
              <iframe name=ad frameborder=0 width=100% height=30 scrolling=no src=admin_upload.asp?fpath=smallpic></iframe></td>
          </tr>
          <tr> 
            <td height="25"> &nbsp;
              <input name="picurl" type="text" class="input" id="picurl2" size="40"></td>
          </tr>
        </table></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" align="center">文件大小：</td>
      <td height="25">&nbsp; 
        <input name="fsize" type="text" id="fsize" value="不详" size="15">
        KB </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" align="center">管理员选项：</td>
      <td height="25">&nbsp;显示 
        <select name="star" size="1" class="input" id="star">
          <option value="★">一星</option>
          <option value="★★" selected>二星</option>
          <option value="★★★">三星</option>
          <option value="★★★★">四星</option>
          <option value="★★★★★">五星</option>
        </select>
        　 <input name="ishot" type="checkbox" id="ishot" value="true">
        热门　 <input name="isgood" type="checkbox" id="isgood" value="true">
        推荐　 <input name="ispassed" type="checkbox" id="ispassed" value="true" checked>
        审核</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" align="center">简短说明：</td>
      <td height="25">&nbsp; 
        <textarea name="remark" cols="45" rows="10" class="input" id="remark"></textarea></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="30" colspan="2" align="center"> 
        <input name="add" type="submit" class="button" id="add" value=" 确定添加 ">
        　 
        <input name="Submit2" type="reset" class="button" value=" 重新填写 "> </td>
    </tr>
  </table>
</form>
<%
end sub

sub addsave()

'01 Flash添加
if not checkflag("01") then
  call mb("对不起，您没有Flash添加的权限！","",0)
end if

dim flashname,bigclassid,smallclassid,url,picurl,remark
dim url2,ishot,isgood,ispassed,star,fsize
flashname=checkstr(trim(request.form("flashname")))
url=checkstr(trim(request.form("url")))
url2=checkstr(trim(request.form("url2")))
picurl=checkstr(trim(request.form("picurl")))
fsize=checkstr(trim(request.form("fsize")))
star=request("star")
ishot=request("ishot")
isgood=request("isgood")
ispassed=request("ispassed")
remark=checkstr(trim(request.form("remark")))

bigclassid=request.form("bigclassid")
smallclassid=request.form("smallclassid")

if not isinteger(bigclassid) then
  call mb("请选择大类ID","",0)
end if
if not isinteger(smallclassid) then
  call mb("请选择小类ID","",0)
end if

if flashname="" or strlength(flashname)>25 then
  call mb("Flash名称不能为空，或大于25个字符！","",0)
end if

if url="" then
  call mb("Flash观看地址不能为空！","",0)
end if

if remark="" then
  call mb("Flash说明不能为空！","",0)
end if

if ishot="" then
  ishot=false
end if

if isgood="" then
  isgood=false
end if

if ispassed="" then
  ispassed=false
end if

if fsize="" then
  fsize="不详"
end if

set rs=server.createobject("adodb.recordset")
sql="select * from flash where id is null"
rs.open sql,conn,1,3

rs.addnew
rs("bigclassid")=bigclassid
rs("smallclassid")=smallclassid
rs("flashname")=flashname
rs("url")=url
rs("url2")=url2
rs("picurl")=picurl
rs("star")=star
rs("ishot")=ishot
rs("isgood")=isgood
rs("ispassed")=ispassed
rs("remark")=remark
rs("username")="侠名"
rs("fsize")=fsize
rs.update

rs.close
call mb("添加Flash成功！","admin_flash.asp?action=add",1)

end sub

sub main()

'02 Flash管理
if not checkflag("02") then
  call mb("对不起，您没有Flash管理的权限！","",0)
end if
response.expires=0
  
currentpage=request("page")
if not isinteger(currentpage) then
  currentpage=1
else
  currentpage=clng(currentpage)
end if

maxperpage=25
totalrecords=0
totalpage=1
i=1

set rs=server.createobject("adodb.recordset")

if action="search" then
  dim searchtype,keyword
  searchtype=request("searchtype")
  keyword=checkstr(trim(request("keyword")))
  if searchtype="" then
   searchtype="flashname"
  end if
  
  if searchtype="id" then
    if not isinteger(keyword) then
	  sql="select * from flash where flashname like '%"&keyword&"%' order by id desc"
	else
	  sql="select * from flash where id="&keyword&" order by id desc"
	end if
  else
    sql="select * from flash where flashname like '%"&keyword&"%' order by id desc"
  end if
else
 sql="select * from flash  order by id desc"
end if

rs.open sql,conn,1,1

if not(rs.bof and rs.eof) then
  rs.pagesize=maxperpage
  rs.absolutepage=currentpage
  totalpage=rs.pagecount
  totalrecords=rs.recordcount
end if
%>
<br>
<script language=javascript>
<!--
function checksearch()
 {
  if (search.keyword.value=="")
   {alert("请输入要查询的内容");
    search.keyword.focus();
    return false;
   }
 return true;
}
-->
</script>
<form action="?action=search" method="post" name="search" id="search">
  <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr> 
      <td width="16%" align="right">作品搜索：</td>
      <td width="60%"><input name="keyword" type="text" class="input" id="keyword" value="<%=request("keyword")%>" size="20">
        　 
        <select name="searchtype" size="1" class="input" id="searchtype">
          <option value="flashname">Flash名称</option>
          <option value="id">ID搜索</option>
        </select> </td>
      <td width="24%"><input name="Submit" type="submit" class="button" value="搜索" onclick="return checksearch();"></td>
    </tr>
  </table>
</form>
<br>

<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  <tr align="center" bgcolor="#EFEBEF"> 
    <td width="6%" height="22"><font color="#000000">ID</font></td>
    <td width="29%" height="22"><font color="#000000">Flash名称</font></td>
    <td width="25%" height="20"><font color="#000000">Flash分类</font></td>
    <td width="10%" height="20"><font color="#000000">上传用户</font></td>
    <td width="12%" height="20"><font color="#000000">添加日期</font></td>
    <td width="18%" height="20"><font color="#000000">操　作</font></td>
  </tr>
  <%do until rs.eof or i>maxperpage%>
  <tr bgcolor="#FFFFFF"> 
    <td height="22">&nbsp;<%=rs("id")%></td>
    <td height="22">&nbsp;<a href="flash_play.asp?id=<%=rs("id")%>" title="在线欣赏Flash作品..." target=_blank><%=rs("flashname")%></a></td>
    <td height="20">&nbsp;<a href="showsmall.asp?classid=<%=rs("bigclassid")%>" title="查看详细..." target=_blank><%=ShowBigClassName(rs("bigclassid"))%></a>&nbsp;->&nbsp;<a href="showflash.asp?smallclassid=<%=rs("smallclassid")%>" title="查看详细..." target=_blank><%=ShowSmallClassName(rs("smallclassid"))%></a></td>
    <td height="20">&nbsp;<a href="showuser.asp?username=<%=rs("username")%>" title="查看用户：<%=rs("username")%> 的详细资料.." target=_blank><%=rs("username")%></a></td>
    <td height="20">&nbsp;<%=formatdatetime(rs("dateandtime"),2)%></td>
    <td height="20" align="center">&nbsp;<a href="make_html.asp?id=<%=rs("id")%>" title="在线欣赏Flash作品..." target=_blank>生成</a> 
      <a href="admin_flashedit.asp?id=<%=rs("id")%>" title="编辑作品：<%=rs("flashname")%> 的信息..">
      <a href="admin_flashedit.asp?id=<%=rs("id")%>" title="编辑作品：<%=rs("flashname")%> 的信息.."></a><a href="admin_flashedit.asp?id=<%=rs("id")%>" title="编辑作品：<%=rs("flashname")%> 的信息..">编辑</a> 
      <a href="admin_flashdel.asp?id=<%=rs("id")%>" title="删除作品：<%=rs("flashname")%> 的信息..." onclick="javascript:if(confirm('是否真的要删除Flash作品：<%=rs("flashname")%>吗？\n\n系统提示：删除后不可恢复！')){return true;}else{return false;}">删除</a></td>
  </tr>
  <%rs.movenext
   i=i+1
   loop
  %>
  <tr bgcolor="#FFFFFF"> 
    <td height="22" colspan="6"> 
      <%if totalrecords>0 then call showpage("admin_flash.asp?action="&action&"&keyword="&keyword&"&searchtype="&searchtype,totalrecords,maxperpage,true,true,"个Flash")%>
    </td>
  </tr>
</table><br>
<%
rs.close
set rs=nothing
end sub
%>
</body>
</html>
