<%
'乘风多用户计数器
'作者QQ：178575
'作者EMail：yliangcf@163.com
'作者网站：http://www.qqcf.com
'详细简介：http://www.qqcf.com/cfcount.htm
'上面有程序在线演示，安装演示，使用疑难解答，最新版本下载等内容
'因为这些内容可能时常更新，没有放在程序里，请自己上网站上查看
%>
<%If SysCode="" Then Response.End%>

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


Sql="Select Top 1 MyCounter,AddDate From CFCount_Count_Day Where UserName='"&UserName&"' Order By MyCounter Desc"
Set Rs=Conn.Execute(Sql)
If Not Rs.Eof Then
 TopShow=Rs("MyCounter")
 TopShowDate=Rs("AddDate")
Else
 TopShow=0
 TopShowDate=""
End If
Rs.Close

Sql="Select Top 1 IpCounter,AddDate From CFCount_Count_Day Where UserName='"&UserName&"' Order By IpCounter Desc"
Set Rs=Conn.Execute(Sql)
If Not Rs.Eof Then
 TopIp=Rs("IpCounter")
 TopIpDate=Rs("AddDate")
Else
 TopIp=0
 TopIpDate=""
End If
Rs.Close

Sql="Select Top 1 MyCounter,AddDate From CFCount_Count_Day Where UserName='"&UserName&"' And DateDiff('d','"&RsUser("AddTime")&"',AddDate)>0 And DateDiff('d',AddDate,Date())>0 Order By MyCounter"
Set Rs=Conn.Execute(Sql)
If Not Rs.Eof Then
 LowShow=Rs("MyCounter")
 LowShowDate=Rs("AddDate")
Else
 LowShow=0
 LowShowDate=""
End If
Rs.Close

Sql="Select Top 1 IpCounter,AddDate From CFCount_Count_Day Where UserName='"&UserName&"' And DateDiff('d','"&RsUser("AddTime")&"',AddDate)>0 And DateDiff('d',AddDate,Date())>0 Order By IpCounter"
Set Rs=Conn.Execute(Sql)
If Not Rs.Eof Then
 LowIp=Rs("IpCounter")
 LowIpDate=Rs("AddDate")
Else
 LowIp=0
 LowIpDate=""
End If
Rs.Close
%>
<table class="tb_1">
<tr class="tr_1">
<td>您好用户：<%=UserName%>
<%
Set Rs= Server.CreateObject("Adodb.RecordSet")
Sql="Select * From CFCount_User Where UserName='"&UserName&"'"
Rs.Open Sql,Conn,1,1
If Rs("UserState")=0 Then Response.Write "&nbsp;&nbsp;<font color=#ff0000>你的账号已被禁用!</font>"

If Rs("ParentName")<>"" Then Response.Write "&nbsp;&nbsp;你的父账号是:"&Rs("ParentName")
%>
	  </td>
</tr>
<tr> 
<td>常用设置链接：[<a href="?Action=jsqquickset">计数器基本样式快速设置</a>]&nbsp;[<a href="?Action=jsqset">计数器参数设置</a>]&nbsp;[<a href="?Action=stylelist">计数器图片样式选择</a>]&nbsp;[<a href="?Action=webcodeget">预览及获得计数器代码</a>]&nbsp;[<a href="?Action=pwdmodify">修改密码</a>]&nbsp;</td>
</tr>
</table>
<table class="tb_1">
<tr class="tr_1">
<td colspan="4"> 统计概况</td>
</tr>
<tr> 
<td width="15%" class="td_r">网站名称：</td>
<td colspan="3" ><%=RsUser("PageName")%></td>
</tr>
<tr> 
<td class="td_r">站点地址：</td>
<td colspan="3" ><a href="<%=RsUser("PageUrl")%>" target="_blank"><%=RsUser("PageUrl")%></a></td>
</tr>
<tr> 
<td class="td_r">开始统计于：</td>
<td colspan="3" ><%=RsUser("AddTime")%></td>
</tr>
<tr> 
<td class="td_r">已统计天数：</td>
<td colspan="3" ><%=DateDiff("d",RsUser("AddTime"),Now())%>天</td>
</tr>
<tr> 
<td class="td_r">在线人数：</td>
<td colspan="3" >
<%
If IsEmpty(Application("CFCountOnline_"&UserName)) Then
 OnlineTotal=0
Else
 Myarray=Split(Application("CFCountOnline_"&UserName),"|")
 OnlineTotal=Ubound(Myarray)
End If
Response.Write OnlineTotal&"人"%></td>
</tr>
<tr> 
<td></td>
<td width="62"  class="td_r">浏览量 
</td>
<td width="84"  class="td_r">访问量 
</td>
<td width="407"  class="td_r"></td>
</tr>
<tr> 
<td class="td_r">总量：</td>
<td><%=RsUser("RealShowTotal")%></td>
<td><%=RsUser("RealIpTotal")%></td>
<td></td>
</tr>
<tr> 
<td  class="td_r">今日流量：</td>
<%
Sql="Select MyCounter,IpCounter From CFCount_Count_Day Where UserName='"&UserName&"' And DateDiff('d',AddDate,Date())=0"
Set Rs=Conn.Execute(Sql)
If Not Rs.Eof Then
TodayShow=Rs("MyCounter")
TodayIp=Rs("IpCounter")
Else
TodayShow=0
TodayIp=0
End If
%>
<td><%=TodayShow%></td>
<td><%=TodayIp%></td>
<td>最高访问量： <%=TopIp%> IP (发生在: <%=TopIpDate%>) </td>
</tr>
<%
Sql="Select MyCounter,IpCounter From CFCount_Count_Day Where UserName='"&UserName&"' And DateDiff('d',AddDate,Date())=1"
Set Rs=Conn.Execute(Sql)
If Not Rs.Eof Then
 MyCounter=Rs("MyCounter")
 IpCounter=Rs("IpCounter")
Else
 MyCounter=0
 IpCounter=0
End If
%>
<tr> 
<td class="td_r">昨日流量：</td>
<td><%=MyCounter%></td>
<td><%=IpCounter%></td>
<td>最高浏览量： <%=TopShow%> PV (发生在: <%=TopShowDate%>)</td>
</tr>
<%
Sql="Select Sum(MyCounter),Sum(IpCounter) From CFCount_Count_Day Where UserName='"&UserName&"' And DateDiff('m',AddDate,Date())=0"
Set Rs=Conn.Execute(Sql)
%>
<tr> 
<td class="td_r">本月累计：</td>
<td><%=Rs(0)%></td>
<td><%=Rs(1)%></td>
<td>&nbsp;</td>
</tr>
<%
Sql="Select Sum(MyCounter),Sum(IpCounter) From CFCount_Count_Day Where UserName='"&UserName&"' And DateDiff('yyyy',AddDate,Date())=0"
Set Rs=Conn.Execute(Sql)
%>
<tr> 
<td class="td_r">今年累计：</td>
<td><%=Rs(0)%></td>
<td><%=Rs(1)%></td>
<td>最低访问量： <%=LowIp%> IP (发生在: <%=LowIpDate%>)</td>
</tr>
<tr> 
<td class="td_r">平均每日：</td>
<td><%=Int(RsUser("RealShowTotal")/DateDiff("d",RsUser("AddTime"),Now()+1))%></td>
<td><%=Int(RsUser("RealIpTotal")/DateDiff("d",RsUser("AddTime"),Now()+1))%></td>
<td>最低浏览量： <%=LowShow%> Pv (发生在: <%=LowShowDate%>)</td>
</tr>
<tr> 
<td class="td_r">预计今日：</td>
<td> 
<%
MyTime=DateDiff("n",Date(),Now())
If MyTime=0 Then MyTime=1
Response.write Int(TodayShow*1440/MyTime)
%>
</td>
<td> 
<%Response.write Int(TodayIp*1440/MyTime)%>
</td>
<td>&nbsp;</td>
</tr>
</table>
		
		
<%If RsUser("ParentName")="" And Session("CFCountUser_View")="" Then'为父账号且是管理员时%>		
<table class="tb_1">
<tr class="tr_1">
<td colspan="4"> 子账号</td>
</tr>
<tr> 
<td colspan="4" ><input type="submit" name="Submit" value="添加子账号" onclick="location.href='?Action=subadd'">
如果你有多个网站需要分别进行统计，可以增加子账号，无需注册多个用户名</td>
</tr>
<tr> 
<td colspan="4" >已开通的子账号：</td>
</tr>
<%
Sql="Select * From CFCount_User Where ParentName='"&UserName&"'"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.open Sql,Conn,1,1
%>
<%
If Rs.Eof Then
%>
<tr> 
<td colspan="4" >暂时没有子账号</td>
</tr>
<%
Else
%>
<tr> 
<td>用户名</td>
<td>站点名称</td>
<td>域名</td>
<td></td>
</tr>
<%
End If%>
<%
While Not Rs.Eof
%>
<tr> 
<td><%=Rs("UserName")%></td>
<td><%=Rs("PageName")%></td>
<td><a href="<%=Rs("PageUrl")%>" target="_blank"><%=Rs("PageUrl")%></a></td>
<td><input type="submit" name="Submit" value="进入管理" onclick="location.href='?Action=subgoto&SubUserName=<%=Rs("UserName")%>'">&nbsp;&nbsp;&nbsp;<a href="?Action=submodify&SubUserName=<%=Rs("UserName")%>">修改</a>&nbsp;&nbsp;&nbsp;<a href="?Action=subdel&SubUserName=<%=Rs("UserName")%>" onClick="{if(confirm('确定要删除这个子账号么，删除后此子账号时统计数据将不存在!')){return true;}return false;};">删除账号</a></td>
</tr>
<%
 Rs.MoveNext
 Wend
%>
</table>
<%End If%>