日期:2012-01-06  浏览次数:21133 次

/*
原创:豆腐
请大家在转载和使用的时候 保留这条信息
*/
/* dbcn.asp
创建数据库连接的 公用程序
*/
<%
function OpenConn()
'创建数据库连接
dim ConnStr
dim uid
dim pwd
dim db
uid="BBC"
pwd="BBC"
db="BBC"
Softserver="Softdepserver"
Set Conn = Server.CreateObject("ADODB.Connection")
ConnStr="Provider=SQLOLEDB.1;UID=" & uid & ";PWD=" & pwd & ";database=" & db & ";server=" & Softserver & ""

Conn.Open ConnStr

set OpenConn=Conn
end function

function OpenRst()
'创建数据库记录集
set Rst=Server.CreateObject ("ADODB.Recordset")
set OpenRst=Rst
end function
%>
/*
staticFunc
统计程序所需要用到的函数库
*/
<!--#include file="dbcn.asp"-->
<%
set conn=openConn()
set rst=openRst()
sub WriteDateTable(intStart,intEnd,strArray,ccount)
'生成统计表
%>
<table border=1 width=100%>
<%for i= intStart to intEnd%>
<tr>
<td width=30%><%=strArray(i)%></td>
<td width=60%>
<%
if rst.eof then
setbar 0,ccount
else
if rst(1)=i then
setbar rst(3),ccount
if not rst.eof then rst.movenext
else
setbar 0,ccount
end if
end if
%>
</td>
</tr>
<%next%>
</table>
<%
end sub
%>
<%
sub setBar(num,ccount)
'生成统计条
if ccount=0 then
percent=0
else
percent=cInt(num/ccount*10000)/100
end if
strGif="bar.gif"
%>
<img src="<%=strGif%>" width="<%=percent+5%>" height=10><font color=red><%=percent%>%</font>
<td align=center>
<%=num%>
</td>
<%
end sub
%>
<%
sub writeDayStatic(userid)
'生成日统计
i=0
dim strArray(100)
for i=0 to 23
strArray(i)= cStr(i) & "点--" & cstr(i+1) & "点"
next
i=0
set rst=openRst()
strSQL="select sum(num) as ccount from dateStatic where userid='" & userid & "'"
rst.open strSQL,conn,3,3
if isnull(Rst("ccount")) then
ccount=0
else
ccount=Rst("ccount")
end if
strSQL="select * from dateStatic where userid='" & userid & "' order by hourid"
set rst=openRst()
rst.open strSQL,conn,3,3
%>
访问总数<%=ccount%>
<table border=1 width=100%>
<tr height=100%>
<td width=50%><% WriteDateTable 0, 11, strArray ,ccount %></td>
<td width=50%><%WriteDateTable 12, 23, strArray ,ccount %></td>
</tr>
</table>
<%
end sub
%>
<%
sub writeWeekStatic(userid)
'生成周统计
i=0
dim strArray(7)
strArray(0)="星期日"
strArray(1)="星期一"
strArray(2)="星期二"
strArray(3)="星期三"
strArray(4)="星期四"
strArray(5)="星期五"
strArray(6)="星期六"
i=0
strSQL="select sum(num) as ccount from weekStatic where userid='" & userid & "'"
set rst=openRst()
rst.op