<%
'乘风多用户计数器 Sql版
'作者QQ：178575
'作者EMail：yliangcf@163.com
'作者网站：http://www.qqcf.com
'详细简介：http://www.qqcf.com/cfcount.htm
'上面有程序在线演示，安装演示，使用疑难解答，最新版本下载等内容
'因为这些内容可能时常更新，就没有放在程序里，请自己上网站上查看
'有完整版本的演示
%>
<table class="tb_1">
  <tr class="tr_1">
    <td>上传图片</td>
  </tr>
  <tr> 
    <td>
<iframe style="top:2px" ID="UploadFiles" src="CF_upfile.asp?UserType=0&CheckCode=<%=RsSet("AdminCode")%>" frameborder=0 scrolling=no width="750" height="25" allowtransparency="true"></iframe></td>
  </tr>
<%
ImgType=CInt(ChkStr(Request("ImgType"),2))
ImgClass=CInt(ChkStr(Request("ImgClass"),2))
ID=ChkStr(Request("ID"),2)
FileName=ChkStr(Request("FileName"),1)
ImgUserType=CInt(ChkStr(Request("ImgUserType"),2))


Sql="Select FileName From CFCount_Upfile Where FileName='"&RsSet("ImgDefaultFileName")&"'"
Set Rs=Conn.Execute(Sql)
If Rs.Eof Then
 ImgDefaultFileNameStr="（注：<font color='#ff0000'>没有设置默认图片</font>）"
Else
 ImgDefaultFileNameStr="（注：设置默认的图片文件名是："&RsSet("ImgDefaultFileName")&"）"
End If
Rs.Close
%>
  <tr class="tr_1">
    <td>上传图片管理<%=ImgDefaultFileNameStr%></td>
  </tr>
  <tr> 
  



  <tr>
    <td><table border="0" cellpadding="0" cellspacing="0" width=100%>


<%



Sql="Select a.*,b.setdesc From CFCount_Upfile a left join CFCount_SetContent b on a.imgclass=b.setflag_2 and b.SetBClassFlag='AdminClass' And b.SetSClassFlag='AdminClass_ImgClass' Where 1=1"
If ImgType=1 Then Sql=Sql&" And a.UserName=''"
If ImgType=2 Then Sql=Sql&" And a.UserName<>''"
If ImgType=3 Then Sql=Sql&" And a.UserName<>'' And a.FileState=0 And a.FileShare=-1"
If ImgClass<>0 Then Sql=Sql&" And a.ImgClass="&ImgClass
If ID<>"" Then Sql=Sql&" And a.ID = "&ID
If FileName<>"" Then Sql=Sql&" And a.FileName like '%"&FileName&"%'"
If ImgUserType<>0 Then Sql=Sql&" And a.ImgUserType="&ImgUserType
Sql=Sql&" Order By a.AddTime Desc"


Set Rs=Server.CreateObject("Adodb.RecordSet")
Rs.open Sql,Conn,1,1

linenum=3
tdwidth=int(100/linenum)&"%"
jishu=1

If Not rs.eof then
 If ChkStr(Request("Page"),2) = "" Then
  Page = 1
 Else 
  Page = CInt(ChkStr(Request("Page"),2))
 End If
 
 rs.pagesize=30
 totalrs=rs.RecordCount
 totalpage=rs.pageCount
 mypagesize=rs.pagesize
 rs.absolutepage=page
End If
While Not Rs.Eof And MyPageSize>0

if jishu mod linenum=1 or linenum=1 then
Response.write "<tr>"
end if%>
            <td width="<%=tdwidth%>" valign="top">
<%
Response.write "<img src='Upload/"&Rs("FileName")&"'><br>"
Response.write "编号："&Rs("ID")&"<br>"
Response.write "上传人："
If Rs("UserName")="" Then
 Response.write "管理员"
Else
 Response.write Rs("UserName")
End If
Response.write "<br>"

Response.write "文件大小：" & CInt(Rs("FileSizeNum")/1024) &"k<br>"

Response.write "使用人数："
Sql="Select Count(*) From CFCount_User Where ImgFileName='"&Rs("FileName")&"'"
Set Rs2=Conn.Execute(Sql)
Response.write Rs2(0)

If Rs2(0)=0 Then
 AlertStr="确定要删除吗?"
 AlertStr_2="确定要设置不通过吗？"
Else
 AlertStr="这个图片已经有"&Rs2(0)&"个用户在使用，删除后使用此图片的用户将改用默认图片，确定要删除吗?"
 AlertStr_2="这个图片已经有"&Rs2(0)&"个用户在使用，确定要设置不通过吗？"
End If
Rs2.Close()
Response.write "<br>"

Response.write "使用权限："
 If Rs("ImgUserType")=1 Then
  Response.write "所有用户<br>"
 Else
  Response.write "<font color='#ff0000'>VIP用户</font><br>"
 End If

Response.write "图片分类："&Rs("SetDesc")&"<br>"

Response.write "上传时间："&Rs("AddTime")&"<br>"

Response.write "操作：<a href='?Action=imgset&FileName="&Rs("FileName")&"'>配置参数</a>&nbsp;&nbsp;"
If Rs("FileName")=RsSet("ImgDefaultFileName") Or Rs("FileName")="default.jpg" Then
 If Rs("FileName")=RsSet("ImgDefaultFileName") Then
  Response.write "网店统计默认图片,禁删<br>"
 End If
 
 If Rs("FileName")="default.jpg" Then
  Response.write "网站统计默认图片,禁删<br>"
 End If
Else
 Response.write "<a href='AdminUser.aspx?Action=imgdefaultsetsave&FileName="&Rs("FileName")&"' onClick=""return confirm('确定要设置这张图片为默认的图片吗?')"">设为默认图片</a>&nbsp;&nbsp;"
 Response.write "<a href='AdminUser.aspx?Action=imgdel&FileName="&Rs("FileName")&"' onClick=""return confirm('"&AlertStr&"')"">删除</a><br>"
End If

'用户的图片设置共享时，管理员审核
If Rs("UserName")<>"" And Rs("FileShare")=-1 Then
 If Rs("FileState")=0 Then
  Response.write "共享未通过审核&nbsp;&nbsp;<a href='AdminUser.aspx?Action=filestatemodifysave&Filename="&Rs("FileName")&"&FileState=-1'>设置通过</a>"
 Else
  Response.write "共享已通过审核&nbsp;&nbsp;<a href='AdminUser.aspx?Action=filestatemodifysave&Filename="&Rs("FileName")&"&FileState=0' onClick=""return confirm('"&AlertStr_2&"')"">设置不通过</a>"
 End If
End If
%> </td>
<%
if jishu mod linenum=0 then
Response.write "</tr>"
end if
jishu=jishu+1
mypagesize=mypagesize-1
Rs.movenext
wend '写tr和td,jishu mod 列数为1时开始tr,为0时结束tr

jishu=jishu-1
if jishu mod linenum <> 0 then
for i= 1 to linenum-(jishu mod linenum)
	response.write "<td width='"&tdwidth&"'>&nbsp;</td>"
	if  i = linenum-(jishu mod linenum) then response.write "</tr>"
next
end if '判断最后一行tr是否正好闭合,否则增加td,里面填入空格
%>
        </table></td>
  </tr>
</table>

<table class="tb_3">
  <tr>
    <td><a href="?Action=<%=Action%>&ImgType=<%=ImgType%>&ImgClass=<%=ImgClass%>&ID=<%=ID%>&FileName=<%=FileName%>&ImgUserType=<%=ImgUserType%>&Page=1">第一页</a>
            <%
if page>1 then%>
            <a href='?Action=<%=Action%>&ImgType=<%=ImgType%>&ImgClass=<%=ImgClass%>&ID=<%=ID%>&FileName=<%=FileName%>&ImgUserType=<%=ImgUserType%>&Page=<%=Page-1%>'>上一页</a>
            <%
end if
%>
            <%
if page<rs.pagecount   then%>
            <a href='?Action=<%=Action%>&ImgType=<%=ImgType%>&ImgClass=<%=ImgClass%>&ID=<%=ID%>&FileName=<%=FileName%>&ImgUserType=<%=ImgUserType%>&Page=<%=Page+1%>'>下一页</a>
            <%

end if
%>
            <a href="?Action=<%=Action%>&ImgType=<%=ImgType%>&ImgClass=<%=ImgClass%>&ID=<%=ID%>&FileName=<%=FileName%>&ImgUserType=<%=ImgUserType%>&Page=<%=totalpage%>">最后一页</a> 页次：<font color="#ff0000"><%=page%></font>/<%=totalpage%>页&nbsp;&nbsp;共<%=totalrs%>条记录&nbsp;&nbsp;每页显示<%=rs.pagesize%>条

<%
Response.write "&nbsp;&nbsp;转到第<select id='page' onChange=""window.location=document.getElementById('page').options[document.getElementById('page').selectedIndex].value"">"
For I=1 To TotalPage
    Response.Write "<option value=?Action="&Action&"&ImgType="&ImgType&"&ImgClass="&ImgClass&"&ID="&ID&"&FileName="&FileName&"&ImgUserType="&ImgUserType&"&Page="&i
 If Page=I Then Response.Write " selected"
 Response.Write ">"& I &"</option>"
Next
Response.write "</select>页"
%>
</td>
  </tr>
</table>


<script language=JavaScript>
function searchcheck_img()
{ 
 var searchurl ="?Action=<%=Action%>"
 searchurl += '&ImgType=' + document.getElementById('ImgType').value;
 searchurl += '&ImgClass=' + document.getElementById('ImgClass').value;
 searchurl += '&ID=' + document.getElementById('ID').value;
 searchurl += '&FileName=' + document.getElementById('FileName').value;
 searchurl += '&ImgUserType=' + document.getElementById('ImgUserType').value;
 document.getElementById('form_img').action = searchurl ;
 return true;
}
</script>
  <form name="form_img" id="form_img" method="post" action="?Action=<%=Action%>" onsubmit="return searchcheck_img()">
<table class="tb_3"><tr class="tr_1">
<td colspan='2' > 
  搜索</td>
</tr>

<tr>
  <td>用户类型  ：  </td>
  <td ><select name="ImgType" id="ImgType">
<option value='0'<%If ImgType=0 Then Response.write " selected"%>>全部</option>
<option value='1'<%If ImgType=1 Then Response.write " selected"%>>系统管理员上传</option>
<option value='2'<%If ImgType=2 Then Response.write " selected"%>>用户上传</option>
<option value='3'<%If ImgType=3 Then Response.write " selected"%>>用户上传(仅共享后未审核)</option>
</select></td>
</tr>
<tr>
  <td>图片类型：</td>
  <td ><select name="ImgClass" id="ImgClass">
<option value='0'>全部</option>
<%
Sql="Select * From CFCount_SetContent Where SetBClassFlag='AdminClass' And SetSClassFlag='AdminClass_ImgClass' Order By SetTaxis"
Set Rs=Conn.Execute(Sql)
While Not Rs.Eof
 Response.write "<option value='"&Rs("SetFlag_2")&"'"
 If ImgClass=CInt(Rs("SetFlag_2")) Then Response.write " selected"
 Response.write ">"&Rs("SetDesc")&"</option>"
Rs.MoveNext
Wend
%>
</select></td>
</tr>
<tr>
  <td>图片ID</td>
  <td ><input name="ID" type="text" id="ID" value="<%=ID%>" size="10" />&nbsp;</td>
</tr>
<tr>
  <td>图片名</td>
  <td ><input name="FileName" type="text" id="FileName" value="<%=FileName%>" size="10" />&nbsp;</td>
</tr>

<tr>
<td>图片权限：</td>
<td>
<select name="ImgUserType" id="ImgUserType">
<option value='0'<%If ImgUserType=0 Then Response.write " selected"%>>全部</option>
<option value='1'<%If ImgUserType=1 Then Response.write " selected"%>>所有用户可使用</option>
<option value='2'<%If ImgUserType=2 Then Response.write " selected"%>>仅VIP用户可使用</option>
</select>
</td>
</tr>
	
<tr>
  <td>&nbsp;</td>
  <td ><input type=submit name="submit" value="搜索"></td>
</tr>
</table></form>
