<%
'乘风多用户计数器 Sql版
'作者QQ：178575
'作者EMail：yliangcf@163.com
'作者网站：http://www.qqcf.com
'详细简介：http://www.qqcf.com/cfcount.htm
'上面有程序在线演示，安装演示，使用疑难解答，最新版本下载等内容
'因为这些内容可能时常更新，就没有放在程序里，请自己上网站上查看
'有完整版本的演示
%>
<%
If Session("CFCountUser_View")<>"" Then'为独立查看者时
 Call AlertBack("独立查看者无法对此操作",1)
End If
%>


<%
If Request("Assort")="" Then
 Assort=2
Else
 Assort=CInt(Request("Assort"))
End if

ImgClass=CInt(ChkStr(Request("ImgClass"),2))
ID=ChkStr(Request("ID"),2)
FileName=ChkStr(Request("FileName"),1)
ImgUserType=CInt(ChkStr(Request("ImgUserType"),2))

Set Rs= Server.CreateObject("Adodb.RecordSet")
Sql="Select * From CFCount_User Where UserName='"&UserName&"'"
Rs.Open Sql,Conn,1,1
ImgFileName=Rs("ImgFileName")
VipState=Rs("VipState")
%>

<script language="JavaScript1.4" type="text/javascript">

//-->
//颜色选择
function SelectColorcmdt(what,backit){
			var dEL = document.all(what);
			var sEL = document.all(backit);
			var url = "images/selcolor.htm?color="+encodeURIComponent(dEL.value);
			var arr = showModalDialog(url,window,"dialogWidth:280px;dialogHeight:250px;help:no;scroll:no;status:no");
			if (arr) {
				dEL.value=arr;
				sEL.style.backgroundColor=arr;
				dEL.style.backgroundColor=arr;
			}
}

    function getMousePostion()
    {
        var obj = document.getElementById('postionX');
        if(obj != null)
        {
            obj.value = event.offsetX;
            
        }
        
        obj = document.getElementById('postionY');
        if(obj != null)
        {
            obj.value = event.offsetY-5;
        }
    }

</SCRIPT>

<table class="tb_1">

  <form name="form_imglist" id="form_imglist" method="post" action="User.aspx?Action=imgmodifysave&Assort=<%=Assort%>">
<tr class="tr_1">
      <td colspan="2">你的设置效果如下：</td>
    </tr>
  <tr> 
    <td><a href="<%=Tmp%>" target="_blank"><img src="<%=Tmp%>cf.aspx?c=<%=UserName%>" border="0" title="<%=RsSet("SysTitle")%>" id=imgView onmouseenter=" document.getElementById('TXY').style.display = '';" 
onmousemove=getMousePostion(); onmouseout="document.getElementById('TXY').style.display='none';"></a></td>
<td>
鼠标放到您想要的位置，即会现在左边距离、顶部距离。
<DIV style="height:60px;">
<div style="DISPLAY: none" id=TXY>
<DIV >
左边(X):<INPUT style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; WIDTH: 26px; BORDER-TOP-STYLE: none; BORDER-LEFT-STYLE: none" id=postionX readOnly type=text>像素</DIV>
<DIV>
顶部(Y):<INPUT style="BORDER-BOTTOM-STYLE: none; BORDER-RIGHT-STYLE: none; WIDTH: 26px; BORDER-TOP-STYLE: none; BORDER-LEFT-STYLE: none" id=postionY readOnly type=text>像素</DIV>
</DIV>
</DIV></td>
</tr>
<tr class="tr_1">
      <td colspan="2">网店类</td>
    </tr>
    <tr> 
      <td colspan="2">
<a href="?Action=<%=Action%>&Assort=1" class="t_button"><span<%If Assort=1 Then Response.write " style='color:#FF0000;'"%>>使用自定义图片</span></a>
<a href="?Action=<%=Action%>&Assort=2" class="t_button"><span<%If Assort=2 Then Response.write " style='color:#FF0000;'"%>>使用系统自带图片</span></a>
<a href="?Action=<%=Action%>&Assort=3" class="t_button"><span<%If Assort=3 Then Response.write " style='color:#FF0000;'"%>>使用系统默认图片</span></a>
<a href="?Action=<%=Action%>&Assort=4" class="t_button"><span<%If Assort=4 Then Response.write " style='color:#FF0000;'"%>>使用用户共享图片</span></a>
<a href="?Action=<%=Action%>&Assort=5" class="t_button"><span<%If Assort=5 Then Response.write " style='color:#FF0000;'"%>>用户共享排行</span></a>
<a href="?Action=<%=Action%>&Assort=6" class="t_button"><span<%If Assort=6 Then Response.write " style='color:#FF0000;'"%>>在网店图片上自定义文字</span></a>
</td>
    </tr>

<%
If Assort=1 Then
%>
<tr id="a_1"> 
      <td colspan="2">
<%
If Rs("UpLoadState")=-1 Then
%>	  
<iframe style="top:2px" ID="UploadFiles" src="CF_upfile.asp?UserType=1&CheckCode=<%=Rs("UserCode")%>" frameborder=0 scrolling=no width="750" height="25"> 
</iframe>
<%Else
Response.write "对不起，你的账号没有上传图片的权限!"
End If%>
		
	  </td>
    </tr>
<%End If%>

<%
If Assort=1 Or Assort=2 Or Assort=4 Then
%>
<tr id="a_2"> 
      <td colspan="2" >
	  <table border="0" cellpadding="0" cellspacing="0" width=100%>
<tr><td height="25" colspan='6' bgcolor='#FFFFFF'>
图片分类

</td></tr>
<tr><td colspan='6' bgcolor='#FFFFFF'>

<%
Response.write "<a href='?Action="&Action&"&Assort="&Assort&"' class='t_button'><span"
If ImgClass=0 Then Response.write " style='color:#FF0000;'"
Response.write ">全部分类</span></a>&nbsp;&nbsp;&nbsp;&nbsp;"

Sql="Select * From CFCount_SetContent Where SetBClassFlag='AdminClass' And SetSClassFlag='AdminClass_ImgClass'"
Set Rs=Conn.Execute(Sql)
While Not Rs.Eof

 Response.write "<a href='?Action="&Action&"&Assort="&Assort&"&ImgClass="&Rs("SetFlag_2")&"' class='t_button'><span"
 If ImgClass=CInt(Rs("SetFlag_2")) Then Response.write " style='color:#FF0000;'"
 Response.write ">"&Rs("SetDesc")&"</span></a>&nbsp;&nbsp;&nbsp;&nbsp;"

Rs.MoveNext
Wend
%>
</td></tr>
<%
'列出有效并为共享状态的图片
Sql="Select a.*,b.PageName,b.PageUrl,b.ImgFileName,c.setdesc From CFCount_Upfile a Left Join CFCount_User b On a.UserName=b.UserName Left Join CFCount_SetContent c  on a.imgclass=c.setflag_2 and c.SetBClassFlag='AdminClass' And c.SetSClassFlag='AdminClass_ImgClass' Where 1=1"

If Assort=1 Then Sql=Sql&" And a.UserName='"&UserName&"'"
If Assort=2 Then Sql=Sql&" And a.UserName='' And a.FileState=-1 And a.FileShare=-1"
If Assort=4 Then Sql=Sql&" And a.UserName<>'' And a.FileState=-1 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>"
 
If Rs("ImgUserType")=1 Then
 Response.write "<input type='radio' name='filename' value='"&Rs("FileName")&"'"
 If ImgFileName=Rs("FileName") Then Response.write " checked"
 Response.write " onclick=""{if(confirm('确定要使用这张网店统计图片吗?')){document.getElementById('form_imglist').submit();return true;}return false;};"">选用此图(此图所有用户可用)<br>"
Else
 If VipState=-1 Then
  Response.write "<input type='radio' name='filename' value='"&Rs("FileName")&"'"
  If ImgFileName=Rs("FileName") Then Response.write " checked"
  Response.write " onclick=""{if(confirm('确定要使用这张网店统计图片吗?')){document.getElementById('form_imglist').submit();return true;}return false;};"">选用此图(<font color='#ff0000'>此图仅VIP可用</font>)<br>"
 Else
  Response.write "你无法选用此图(<font color='#ff0000'>此图仅VIP可用</font>)<br>"
 End If
End If


Response.write "编号："&Rs("ID")&"&nbsp;&nbsp;<a href='?Action=imgsetout&FileName="&Rs("FileName")&"'>导出图片配置</a><br>"
Response.write "上传人："
If Rs("UserName")="" Then
 Response.write "管理员"
Else
 Response.write Rs("UserName")&"&nbsp;&nbsp;<a href='"&Rs("PageUrl")&"' target='_blank'>"&Rs("PageName")&"</a>"
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)
Rs2.Close()
Response.write "<br>"

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

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

Response.write "状态："
If Rs("FileState")=-1 Then
Response.write "审核通过"
Else
Response.write "审核未通过"
End If
If Rs("FileShare")=-1 Then
Response.write "&nbsp;&nbsp;共享<br>"
Else
Response.write "&nbsp;&nbsp;不共享<br>"
End If

If Assort=1 And Rs("UserName")=UserName And ((Rs("FileState")=0 And Rs("FileShare")=-1) Or (Rs("FileState")=-1 And Rs("FileShare")=0)) Then
 If Rs("ImgFileName")=Rs("FileName") Then
  Response.write "<a href='?Action=imgset&FileName="&Rs("FileName")&"'>图片参数配置</a><br>"
 Else
  Response.write "选用此图后可对其进行参数配置<br>"
 End If
End If

'不共享 或 共享但还没有通过审核时可以删除
If Rs("UserName")=UserName And (Rs("FileShare")=0 Or (Rs("FileShare")=-1 And Rs("FileState")=0))  Then
 If Rs("FileName")=ImgFileName Then
  AlertStr="此图片正在使用中，删除后将改用默认图片，确定要删除吗?"
 Else
  AlertStr="确定要删除吗?"
 End If
 Response.write "<a href='User.aspx?Action=imgdel&FileName="&Rs("FileName")&"&ImgFileName="&ImgFileName&"' onClick=""return confirm('"&AlertStr&"')"">删除此图片</a><br>"
End If
%>


</td>
<%
if jishu mod linenum=0 then
Response.write "</tr>"
Response.write "<tr><td colspan='6' height='1' bgcolor='#FF0000'></td></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>
<%
ElseIf Assort=3 Then
%>
<tr> 
<td colspan="2">
使用这个默认图片<br />
<img src="upload/<%=RsSet("ImgDefaultFileName")%>" border="0"><br>
<input type='radio' name='filename' value='<%=RsSet("ImgDefaultFileName")%>'<%If ImgFileName=RsSet("ImgDefaultFileName") Then Response.write " checked"%> onclick="{if(confirm('确定要使用这张网店统计图片吗?')){document.getElementById('form_imglist').submit();return true;}return false;};">选用此图
<%
Sql="Select Count(*) From CFCount_User"
Set Rs2=Conn.Execute(Sql)
TotalUser = Rs2(0)
Rs2.Close()

Sql="Select Count(*) From CFCount_User Where ImgFileName='"&RsSet("ImgDefaultFileName")&"'"
Set Rs2=Conn.Execute(Sql)
ThisPicUser = Rs2(0)
Rs2.Close()
Response.write "<br>所有用户："&TotalUser&"人，使用此图："&ThisPicUser&"人"
%>
</td>
</tr>


<%
ElseIf Assort=5 Then
%>
<tr> 
<td colspan="2">
<%
Sql="Select a.UserName,a.ShareTotal,b.PageName,b.PageUrl From ("
Sql=Sql&"Select Top 100 UserName,sum(1) as ShareTotal from CFCount_Upfile where FileState=-1 And FileShare=-1 And UserName<>''  group by username order by ShareTotal Desc"
Sql=Sql&") a Left Join CFCount_user  b on a.username=b.username"


Set Rs=Conn.Execute(Sql)
I=1
While Not Rs.Eof

Response.write "第"&I&"名："&Rs("UserName")&"&nbsp;&nbsp;&nbsp;<a href='"&Rs("PageUrl")&"' target='_blank'>"&Rs("PageName")&"</a><br>"

I=I+1
Rs.MoveNext
WEnd
%>

</td>
</tr>

<%
ElseIf Assort=6 Then
%>

<tr class="tr_1"> 
      <td colspan="2">为自己的网店图片上加上自已的文字(如加入网店ID，防别人盗用自己的统计图片)</td>
    </tr>
	
	<tr> 
      <td>选择字体：</td>
      <td>
	  <select name="UserSelfTextFontName">
	  <%
	  ImgFontAllStyle=GetMySet("CFCountAdminSet","AdminSet","ImgFontAllStyle")
	  MyArray=Split(ImgFontAllStyle,",")
	  For I=0 To Ubound(MyArray)
	   Response.write "<option value='"&MyArray(I)&"'"
	   If Rs("UserSelfTextFontName")=MyArray(I) Then Response.write " selected"
	   Response.write ">"&MyArray(I)&"</option>"
	  Next
	  %>
        </select></td>
    </tr>
	
<tr>
<td>自定义文字1：</td>
<td>
颜色<input name="UserSelfText1FontColor" type=text id="UserSelfText1FontColor" value="<%=rs("UserSelfText1FontColor")%>" size=7  >
<img border=0 src="images/rect.gif" width=18 style="cursor:hand;background-color:<%=rs("UserSelfText1FontColor")%>;" id=As_UserSelfTextFontColor onclick="SelectColorcmdt('UserSelfText1FontColor','As_UserSelfText1FontColor')">
字体大小<input name="UserSelfText1FontSize" type="text" id="UserSelfText1FontSize" value="<%=rs("UserSelfText1FontSize")%>" size="5" >
  象素，左<input name="UserSelfText1FontLeft" type="text" id="UserSelfText1FontLeft" value="<%=rs("UserSelfText1FontLeft")%>" size="5" >象素，
顶<input name="UserSelfText1FontTop" type="text" id="UserSelfText1FontTop" value="<%=rs("UserSelfText1FontTop")%>" size="5" >
象素，
显示文字：
<input name="UserSelfText1FontText" type="text" id="UserSelfText1FontText" value="<%=rs("UserSelfText1FontText")%>" size="10" ></td>
</tr>

<tr>
<td>自定义文字2：</td>
<td>
颜色<input name="UserSelfText2FontColor" type=text id="UserSelfText2FontColor" value="<%=rs("UserSelfText2FontColor")%>" size=7  >
<img border=0 src="images/rect.gif" width=18 style="cursor:hand;background-color:<%=rs("UserSelfText2FontColor")%>;" id=As_UserSelfTextFontColor onclick="SelectColorcmdt('UserSelfText2FontColor','As_UserSelfText2FontColor')">
字体大小<input name="UserSelfText2FontSize" type="text" id="UserSelfText2FontSize" value="<%=rs("UserSelfText2FontSize")%>" size="5" >
  象素，左<input name="UserSelfText2FontLeft" type="text" id="UserSelfText2FontLeft" value="<%=rs("UserSelfText2FontLeft")%>" size="5" >象素，
顶<input name="UserSelfText2FontTop" type="text" id="UserSelfText2FontTop" value="<%=rs("UserSelfText2FontTop")%>" size="5" >
象素，
显示文字：
<input name="UserSelfText2FontText" type="text" id="UserSelfText2FontText" value="<%=rs("UserSelfText2FontText")%>" size="10" ></td>
</tr>

    <tr>
      <td>&nbsp;</td>
      <td>(如颜色留空则表示这一项不会在图片上出现)</td>
    </tr>
    <tr> 
      <td>&nbsp;</td>
      <td>
<%
If Rs("VipState") = 0 And SelfTextState = 0 Then
 Response.write "<font color='#ff0000'>你没有这个权限修改此项，只有VIP用户才有权限自定义此项统计标签</font>"
Else
 Response.write "<input type=""submit"" name=""submit_modify"" value=""修　改"" >"
End If
%></td>
    </tr>



</td>
</tr>

<%End If%>


</form>

<%
If Assort=1 Or Assort=2 Or Assort=4 Then
%>

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

end if
%>
            <a href="?Action=<%=Action%>&Assort=<%=Assort%>&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&"&Assort="&Assort&"&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 += '&Assort=' + document.getElementById('Assort').value;
 searchurl += '&ImgClass=' + document.getElementById('ImgClass').value;
 searchurl += '&ID=' + document.getElementById('ID').value;
 searchurl += '&FileName=' + document.getElementById('SFileName').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="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="SFileName" type="text" id="SFileName" 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="搜索"><input name="Assort" type="hidden" id="Assort" value="<%=Assort%>"/></td>
</tr>

</table></form>




</td>
</tr>




<%End If%>

</table>