<%@language=vbscript codepage=936 %>
<%
option explicit
response.buffer=true	
Const PurviewLevel=2
Const CheckChannelID=0
Const PurviewLevel_Others="AD"
%>
<!--#include file="inc/conn1.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="Admin_ChkPurview.asp"-->
<!--#include file="inc/ubbcode.asp"-->
<!--#include file="inc/function.asp"-->
<%
dim sql,rs,strFileName
dim Action,Channel,FoundErr,ErrMsg
Action=Trim(Request("Action"))

strFileName="Admin_yczx.asp"
%>
<html>
<head>
<title>网站明星</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="Admin_Style.css">
<script language=javascript src="mouse_up.js"></script>
<LINK href="css/adminstyle.css" type=text/css rel=stylesheet>
</head>
<body leftmargin=0 bottommargin=0 rightmargin=0 topmargin=0>
<BR style="OVERFLOW: hidden; LINE-HEIGHT: 3px">
<table border=0 align=center cellspacing=1 class=TableBorder cellpadding=3>	<tr>		<th>网站明星</th>	</tr>	<tr>
	<tr>
	<td class="TableRow1">
	<fieldset style="cursor: default"><legend>&nbsp;网站明星<a name="setting2"></a>[<a href="#top">顶部</a>]</legend><table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="TableBorder2"><br>
<SCRIPT language=javascript>
function unselectall(thisform)
{
    if(thisform.chkAll.checked)
	{
		thisform.chkAll.checked = thisform.chkAll.checked&0;
    } 	
}

function CheckAll(thisform)
{
	for (var i=0;i<thisform.elements.length;i++)
    {
	var e = thisform.elements[i];
	if (e.Name != "chkAll"&&e.disabled!=true)
		e.checked = thisform.chkAll.checked;
    }
}
function ConfirmDel(thisform)
{
	if(thisform.Action.value=="Del")
	{
		if(confirm("确定要删除选中的明星吗？"))
		    return true;
		else
			return false;
	}
}

function check(thisform)
{
	if(thisform.ADType.selectedIndex==6)
	{
		if(thisform.ADCode.value=="")
		{
			alert("明星不能为空！")
			thisform.ADCode.focus()
			return false;
		}
		if(thisform.ADCode.value.length>250)
		{
			alert("明星不能超过250字符！")
			thisform.ADCode.focus()
			return false;
		}
	}
	else
	{
		if(thisform.SiteName.value=="")
		{
		  alert("明星名称不能为空！");
		  thisform.SiteName.focus();
		  return false;
		}
		if(thisform.ImgUrl.value=="")
		{
		  alert("明星图片地址不能为空！");
		  thisform.ImgUrl.focus();
		  return false;
		}
		if(thisform.ADType.selectedIndex==0)
		{
			if(thisform.ImgWidth.value=="")
			{
			  alert("明星图片宽度不能留空！");
			  thisform.ImgWidth.focus();
			  return false;
			}
			if(thisform.ImgHeight.value=="")
			{
			  alert("明星图片高度不能留空！");
			  thisform.ImgHeight.focus();
			  return false;
			}
		}
	}
}
</script></head>
<body leftmargin="10" topmargin="10" marginwidth="10" marginheight="10">
<%
if Action="Add" then
	call Add()
elseif Action="SaveAdd" then
	call SaveAdd()
elseif Action="Modify" then
	call Modify()
elseif Action="SaveModify" then
	call SaveModify()
elseif Action="SetNew" then
	call SetNew()
elseif Action="CancelNew" then
	call CancelNew()
elseif Action="Move" then
	call MoveAdvertisement()
elseif Action="Del" then
	call DelAD()
else
	call main()
end if
if FoundErr=True then
	call WriteErrMsg()
end if
call CloseConn()


sub main()

set rs=server.createobject("adodb.recordset")
rs.open "select * from yczx order by ID desc",conn,1,1 

%>
<form name="form1" method="POST" action=<%=strFileName%> >

  <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
    <tr bgcolor="#f2f2f2" class="title"> 
      <td width="30" height="25" align="center"><strong>选择</strong></td>
      <td width="30" height="25" align="center" bgcolor="#f2f2f2"><strong>ID</strong></td>
      <td width="20" height="25" align="center" bgcolor="#f2f2f2">&nbsp;</td>
      <td width="80" height="25" align="center" bgcolor="#f2f2f2"><strong>推荐类型</strong></td>
      <td width="200" height="25" align="center" bgcolor="#f2f2f2"><strong>标题</strong></td>
      <td height="25" align="center" bgcolor="#f2f2f2"><strong>明星照片片</strong></td>
      <td width="80" height="25" align="center" bgcolor="#f2f2f2"><strong>操作</strong></td>
    </tr>
    <%
if not(rs.bof and rs.eof) then
	do while not rs.eof
%>
    <tr bgcolor="#fafafa"  onmouseover="this.style.backgroundColor='#BFDFFF'" onMouseOut="this.style.backgroundColor=''"> 
      <td width="30" align="center" bgcolor="#FFFFFF"> 
        <input type="checkbox" value=<%=rs("ID")%> name="ID" onClick="unselectall(this.form)"> 
      </td>
      <td width="30" align="center" bgcolor="#FFFFFF"><%=rs("ID")%></td>
      <td width="20" align="center" bgcolor="#FFFFFF">&nbsp;</td>
      <td width="80" align="center" bgcolor="#FFFFFF"> 
        <%
		if rs("hotType")=0 then
			response.write "图片热点" 
		elseif rs("hotType")=1 then
			response.write "文字热点" 
		
		end if
		%>
      </td>
      <td bgcolor="#FFFFFF" ><a href="<%=rs("Url")%>" target='blank' ><%=rs("title")%></a></td>
      <td align="center" bgcolor="#FFFFFF"> 
        <%
		if rs("hotType")=0 then
			response.write "<img src="&rs("pic")&" width=100>" 
		elseif rs("hotType")=1 then
			response.write "文字热点" 
		
		end if
		%>
      </td>
      <td width="80" align="center" bgcolor="#FFFFFF"> 
        <%
	  response.write "<a href='" & strFileName & "?Action=Modify&ID=" & rs("ID") & "'>修改</a>&nbsp;&nbsp;"
		response.write "<a href='" & strFileName & "?Action=Del&ID=" & rs("ID") & "' onclick=""return confirm('确定要删除此明星吗？');"">删除</a>"
	  %>
      </td>
    </tr>
    <%
rs.movenext
loop
%>
    <tr bgcolor="#f2f2f2" > 
      <td height="25" colspan=7> 
        <input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
        选中所有明星 
        <input name="Action" type="hidden" id="Action" value="Del">
        &nbsp;&nbsp;&nbsp;&nbsp;将选定的明星： 
        <input type="submit" value=" 删除 " name="submit" onClick="this.form.Action.value='Del';return ConfirmDel(this.form);"">
      </td>
    </tr>
    <% end if%>
  </table>
</form>
<%
	rs.close
	set rs=nothing
end sub

sub Add()
%>
<form name="myform" method="post" action="<%=strFileName%>" onSubmit="return check(myform)">
  <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC" >
    <tr class="title"> 
      <td height="25" colspan="2" align="center" bgcolor="#f2f2f2"><strong>添 加 
        推 荐</strong></td>
    </tr>
    <tr bgcolor="fafafa" > 
      <td width="15%" align="center" bgcolor="#FFFFFF"><strong>&nbsp;推荐类型：</strong></td>
      <td width="550" bgcolor="#FFFFFF"> 
        <select name="hotType" id="hotType" >
          <option value="0" selected >图片明星</option>
          <option value="1" >文字明星</option>
      </select> </td>
    </tr>
    <tr bgcolor="fafafa" > 
      <td align="center" bgcolor="#FFFFFF"><strong>&nbsp;推荐姓名：</strong></td>
      <td bgcolor="#FFFFFF"> 
        <input name="title" type="text" id="title" value="" size="48" maxlength="255"> 
        <select name="TitleColor" id="TitleColor">
          <option value="" selected>颜色</option>
          <OPTION value="">默认</OPTION>
          <OPTION value="#000000" style="background-color:#000000" ></OPTION>
          <OPTION value="#FF00FF" style="background-color:#FF00FF" ></OPTION>
          <OPTION value="#008000" style="background-color:#008000" ></OPTION>
          <OPTION value="#800000" style="background-color:#800000"></OPTION>
          <OPTION value="#808000" style="background-color:#808000"></OPTION>
          <OPTION value="#000080" style="background-color:#000080"></OPTION>
          <OPTION value="#800080" style="background-color:#800080"></OPTION>
          <OPTION value="#808080" style="background-color:#808080"></OPTION>
          <OPTION value="#FF6130" style="background-color:#FF6130"></OPTION>
          <OPTION value="#99CCFF" style="background-color:#99CCFF"></OPTION>
          <OPTION value="#00FFFF" style="background-color:#00FFFF"></OPTION>
          <OPTION value="#09CDF0" style="background-color:#09CDF0"></OPTION>
          <OPTION value="#FF0000" style="background-color:#FF0000"></OPTION>
          <OPTION value="#0000FF" style="background-color:#0000FF"></OPTION>
          <OPTION value="#008080" style="background-color:#008080"></OPTION>
        </select>
      </td>
    </tr>
    <tr bgcolor="fafafa" > 
      <td align="center" bgcolor="#FFFFFF"><strong>&nbsp;明星介绍：</strong></td>
      <td bgcolor="#FFFFFF"> 
        <input name="Url" type="text" id="Url" value="介绍" size="58" maxlength="255">
      </td>
    </tr>
    <tr bgcolor="fafafa" > 
      <td align="center" bgcolor="#FFFFFF"><strong>&nbsp;图片地址：</strong></td>
      <td bgcolor="#FFFFFF"> 
        <input name="pic" type="text" id="pic" size="58" maxlength="255"> 
        文字推荐时不用填写</td>
    </tr>
    <tr bgcolor="fafafa"   id="settable0"> 
      <td align="center" bgcolor="#FFFFFF"><strong>&nbsp;图片上传：</strong></td>
      <td bgcolor="#FFFFFF"> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0" >
          <tr> 
            <td> <iframe style="top:2px" ID="UploadFiles" src="Upload_hotPic.asp" frameborder=0 scrolling=no width="400" height="25"> 
              </iframe> </td>
          </tr>
      </table></td>
    </tr>
    <tr bgcolor="fafafa" > 
      <td align="center" bgcolor="#FFFFFF"><strong>&nbsp;图片大小：</strong></td>
      <td bgcolor="#FFFFFF">宽： 
        <input name="ImgWidth" type="text" id="ImgWidth" size="6" maxlength="5">
        像素&nbsp;&nbsp;&nbsp;&nbsp;高： 
        <input name="ImgHeight" type="text" id="ImgHeight"  size="6" maxlength="5">
      像素&nbsp;</td>
    </tr>

    <tr> 
      <td height="25" colspan="2" align="center" bgcolor="#f2f2f2"> 
        <input name="Action" type="hidden" id="Action" value="SaveAdd">
        <input type="submit" name="Submit" value=" 添 加 ">
      </td>
    </tr>
  </table>
</form>
<%
end sub

sub Modify()
	dim ID
	ID=trim(request("ID"))
	if ID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定明星ID</li>"
		exit sub
	else
		ID=Clng(ID)
	end if
	sql="select * from yczx where ID=" & ID
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,1
	


%>
<form name="myform" method="post" action="<%=strFileName%>" onSubmit="return check(myform)">
  <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC" >
    <tr class="title"> 
      <td height="25" colspan="2" align="center" bgcolor="#f2f2f2"><strong>修 改 
        推 荐</strong></td>
    </tr>
    <tr bgcolor="fafafa" > 
      <td width="15%" align="center" bgcolor="#FFFFFF"><strong>&nbsp;推荐类型：</strong></td>
      <td width="550" bgcolor="#FFFFFF"> <select name="hottype" id="hottype" >
          <option value="0" <%if rs("hottype")=0 then%>selected<%else%><%end if%> >图片热点</option>
          <option value="1" <%if rs("hottype")=1 then%>selected<%else%><%end if%> >文字热点</option>
      </select> </td>
    </tr>
    <tr bgcolor="fafafa" > 
      <td align="center" bgcolor="#FFFFFF"><strong>&nbsp;推荐姓名：</strong></td>
      <td bgcolor="#FFFFFF"> <input name="title" type="text" id="title" value="<%=rs("title")%>" size="48" maxlength="255">
        <select name="Titlecolor" id="Titlecolor">
          <option value="">颜色</option>
          <OPTION value="">默认</OPTION>
          <OPTION value="#000000" style="background-color:#000000" <%if rs("Titlecolor")="#000000" then response.write " selected"%>></OPTION>
          <OPTION value="#FF00FF" style="background-color:#FF00FF" <%if rs("TitleColor")="#FF00FF" then response.write " selected"%>></OPTION>
          <OPTION value="#008000" style="background-color:#008000" <%if rs("TitleColor")="#008000" then response.write " selected"%>></OPTION>
          <OPTION value="#800000" style="background-color:#800000"<%if rs("TitleColor")="#800000" then response.write " selected"%>></OPTION>
          <OPTION value="#808000" style="background-color:#808000" <%if rs("TitleColor")="#808000" then response.write " selected"%>></OPTION>
          <OPTION value="#000080" style="background-color:#000080" <%if rs("TitleColor")="#000080" then response.write " selected"%>></OPTION>
          <OPTION value="#800080" style="background-color:#800080" <%if rs("TitleColor")="#800080" then response.write " selected"%>></OPTION>
          <OPTION value="#808080" style="background-color:#808080" <%if rs("TitleColor")="#808080" then response.write " selected"%>></OPTION>
          <OPTION value="#FF6130" style="background-color:#FF6130"  <%if rs("TitleColor")="#FF6130" then response.write " selected"%>></OPTION>
          <OPTION value="#99CCFF" style="background-color:#99CCFF" <%if rs("TitleColor")="#99CCFF" then response.write " selected"%>></OPTION>
          <OPTION value="#00FFFF" style="background-color:#00FFFF" <%if rs("TitleColor")="#00FFFF" then response.write " selected"%>></OPTION>
          <OPTION value="#09CDF0" style="background-color:#09CDF0" <%if rs("TitleColor")="#09CDF0" then response.write " selected"%>></OPTION>
          <OPTION value="#FF0000" style="background-color:#FF0000" <%if rs("TitleColor")="#FF0000" then response.write " selected"%>></OPTION>
          <OPTION value="#0000FF" style="background-color:#0000FF" <%if rs("TitleColor")="#0000FF" then response.write " selected"%>></OPTION>
          <OPTION value="#008080" style="background-color:#008080" <%if rs("TitleColor")="#008080" then response.write " selected"%>></OPTION>
      </select> </td>
    </tr>
    <tr bgcolor="fafafa" > 
      <td align="center" bgcolor="#FFFFFF"><strong>&nbsp;明星介绍：</strong></td>
      <td bgcolor="#FFFFFF"> <input name="Url" type="text" id="Url" value="<%=rs("url")%>" size="58" maxlength="255"> 
      </td>
    </tr>
    <tr bgcolor="fafafa" > 
      <td align="center" bgcolor="#FFFFFF"><strong>&nbsp;图片地址：</strong></td>
      <td bgcolor="#FFFFFF"> <input name="pic" type="text" id="pic" value=<%if rs("pic")<>"" then%><%=rs("pic")%><%else%>""<%end if%> size="58" maxlength="255"> 
      </td>
    </tr>
    <tr bgcolor="fafafa"   id="settable0"> 
      <td align="center" bgcolor="#FFFFFF"><strong>&nbsp;图片上传：</strong></td>
      <td bgcolor="#FFFFFF"> <table width="100%" border="0" cellspacing="0" cellpadding="0" >
          <tr> 
            <td> <iframe style="top:2px" ID="UploadFiles" src="Upload_hotPic.asp" frameborder=0 scrolling=no width="400" height="25"> 
              </iframe> </td>
          </tr>
      </table></td>
    </tr>
    <tr bgcolor="fafafa" > 
      <td align="center" bgcolor="#FFFFFF"><strong>&nbsp;图片大小：</strong></td>
      <td bgcolor="#FFFFFF">宽： 
        <input name="ImgWidth" type="text" id="ImgWidth" value="298"  size="6" maxlength="5">
        像素&nbsp;&nbsp;&nbsp;&nbsp;高： 
        <input name="ImgHeight" type="text" id="ImgHeight" value="138"  size="6" maxlength="5">
      像素&nbsp;</td>
    </tr>
    <tr> 
      <td height="25" colspan="2" align="center" bgcolor="#f2f2f2"> <input name="Action" type="hidden" id="Action" value="SaveModify"> 
        <input name="ID" type="hidden" id="ID" value="<%=rs("ID")%>"> 
        <input type="submit" name="Submit" value=" 修 改 "> </td>
    </tr>
  </table>
  <script language=JavaScript>
showsetting(myform)
</script>
</form>
<%
	rs.close
	set rs=nothing
    end sub 
%>
</body>
</html>
<%
sub SaveAdd()
	dim hotType,title,Url,pic,TitleColor
	hotType=trim(request("hotType"))
	title=trim(request("title"))
	Url=trim(request("Url"))
	pic=trim(request("pic"))
	TitleColor=trim(request("TitleColor"))

		if title="" then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>标题不能为空！</li>"
       else
       end if

	if FoundErr=True then
		exit sub
	end if
	
	if Url="介绍" then Url="此明星占无介绍"
	

	sql="select * from yczx"
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,3
	rs.addnew
	rs("hotType")=hotType
	rs("title")=title
	rs("Url")=Url
	rs("pic")=pic
	rs("TitleColor")=TitleColor
	rs("date")=now
	rs.update
	rs.close
	set rs=nothing
	call CloseConn()
	response.redirect "Admin_yczx.asp"
end sub

sub SaveModify()
	dim sql,rs
	dim ID,hotType,title,Url,pic,TitleColor
	ID=trim(request("ID"))
	hotType=trim(request("hotType"))
	title=trim(request("title"))
	Url=trim(request("Url"))
	pic=trim(request("pic"))
	TitleColor=trim(request("TitleColor"))
	if ID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定ID</li>"
	else
		ID=Clng(ID)
	end if
	if title="" then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>标题不能为空！</li>"
       else
       end if

	if FoundErr=True then
		exit sub
	end if
	
	if Url="占无" then Url="占无介绍"


	sql="select * from yczx where ID=" & ID
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,3
	if rs.bof and rs.eof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>找不到指定的ID！</li>"
		rs.close
		set rs=nothing
		exit sub
	end if
	rs("hotType")=hotType
	rs("title")=title
	rs("Url")=Url
	rs("pic")=pic
	rs("TitleColor")=TitleColor
	rs("date")=now
	rs.update
	rs.close
	set rs=nothing
	call CloseConn()
	response.redirect strFileName
end sub


sub DelAD()
	dim ID
	ID=Trim(Request("ID"))
	if ID="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>请指定广告ID</li>"
		exit sub
	end if
	if Instr(ID,",")>0 then
		dim arrID,i
		arrID=split(ID,",")
		for i=0 to Ubound(arrID)
		conn.execute "delete from yczx where ID=" & CLng(arrID(i))
		next
	else
		conn.execute "delete from yczx where ID=" & CLng(ID)
	end if
	response.redirect strFileName
end sub
%>
