📄 showcount.jsp
字号:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.util.Calendar" %>
<%@ page import="cn.js.fan.db.*" %>
<%@ page import="cn.js.fan.web.*" %>
<%@ page import="cn.js.fan.util.*" %>
<%@ page import="java.sql.*" %>
<jsp:useBean id="fchar" scope="page" class="cn.js.fan.util.StrUtil"/>
<jsp:useBean id="privilege" scope="page" class="com.redmoon.oa.pvg.Privilege"/>
<%
if (!privilege.isUserPrivValid(request, "forum.bak"))
{
out.println(cn.js.fan.web.SkinUtil.makeErrMsg(request, cn.js.fan.web.SkinUtil.LoadString(request, "pvg_invalid")));
return;
}
%>
<%!
String connname = Global.defaultDB;
int CountSize = 6; //计数不足在前面加零
boolean CountView = true; //计数是否显示在页面上,False/True
boolean CountType = true; //统计是记时间还是不记.True记,False不记
boolean CountMode = true; //在页面上显示不计时的计数结果,还是显示计时的结果,默认为不计时(计时为:20分钟内不加数)
int Avera,DayMax,AllCount;
//计算两个日期之间相隔的天数
public int DateDiff(java.util.Date lowerLimitDate,java.util.Date upperLimitDate){
long upperTime,lowerTime;
upperTime=upperLimitDate.getTime();
lowerTime=lowerLimitDate.getTime();
if(upperTime<lowerTime)
return -1;
Long result=new Long((upperTime-lowerTime)/(1000*60*60*24));
return result.intValue();
}
public String Right(String str ,int n)
{
return str.substring(str.length()-2);
}
%>
<%
Conn conn = new Conn(connname);
Calendar cal = Calendar.getInstance();
String today = cal.get(cal.YEAR)+"-"+(cal.get(cal.MONTH)+1)+"-"+cal.get(cal.DATE);
//===========================================================================
String NewYear,NewMonth,NewDay;
NewYear = Integer.toString(cal.get(cal.YEAR));
NewMonth = Integer.toString(cal.get(cal.MONTH)+1);
NewDay = Integer.toString(cal.get(cal.DATE));
if (NewYear.length()<=2) NewYear="20" + NewYear;
if (NewMonth.length()<=1) NewMonth="0" + NewMonth;
if (Integer.parseInt(NewDay)<=9) NewDay="0" + NewDay;
//=========================================================================== 基本统计数据
int DayTotal = 0;
ResultSet rs = conn.executeQuery("Select count(*) from DayCount");
if (rs!=null && rs.next())
DayTotal = rs.getInt(1); //获得统计总天数
else
DayTotal = 0;
if (rs!=null) rs.close();
rs = conn.executeQuery("Select * from Count");
java.util.Date StartDate,LogDate=null;
int ToDay=0,TotalDays=0;
if (rs!=null && rs.next())
{
StartDate = rs.getDate("StartDate"); //开始统计日期
DayMax = rs.getInt("DayMax"); //最高一天流量
AllCount = rs.getInt("AllCount"); //统计访问总数(使用的天数)
ToDay = rs.getInt("ToDayCount"); //今天访问流量
LogDate = rs.getDate("LogDate"); //统计截止日期
TotalDays = DateDiff(StartDate,new java.util.Date())+1; //统计访问日期数(不管有没有使用,从开始统计算起.)
Avera = rs.getInt("AllCount") % TotalDays; //日均访问流量
}
if (rs!=null) rs.close();
if (DateDiff(LogDate,new java.util.Date())>=1) ToDay = 0;
//=========================================================================== 预计一天访问量
int intending=(ToDay/(cal.get(cal.HOUR)+1)*(24-cal.get(cal.HOUR)-1)+ToDay);
//===================================================================
String DayID,MonID,YearID;
boolean MyDay;
DayID = request.getParameter("day");
MonID = request.getParameter("mon");
if (DayID==null || !fchar.isNumeric(DayID))
{
DayID = NewDay;
MyDay = false;
}
else
{
DayID = DayID.trim();
MyDay = true;
}
if (MonID==null || !fchar.isNumeric(MonID))
{
MonID = NewYear + NewMonth;
}
else
MonID = MonID.trim();
YearID = MonID.substring(0,4);
String Mon = MonID.substring(MonID.length()-2);
String dToday = YearID + "-" + Mon;
if (DayID.length()<=1)
DayID = "0" + DayID;
if (MonID.length()<=1)
MonID = "0" + MonID;
%>
<%
//===========================================================================
%>
<html>
<head>
<title>蓝风统计系统</title>
<%@ include file="../../inc/nocache.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../../common.css" type="text/css">
<style type="text/css">
<!--
BODY {font-size:9pt;font-family:Tahoma,Verdana,MS Sans Serif,Courier New;}
A:link,A:visited{text-decoration:none;}
A:hover {text-decoration:underline;}
A:hover {text-decoration:overline;color:#FFFF00}
TR,TD,P{font-size:9pt}
B{color:#E1005D;}
INPUT.text,INPUT.file,SELECT,TEXTAREA{color:#000000;background-color:#FFFFFF;border:1 solid #220430}
#TITLE{height:20;Filter: shadow(color=#00AAFF,direction=135);}
.notice{position:relative;height:50;overflow:visible;border:0;z-index:2}
FONT.table{color:#000000}
FONT.strong{color:#FFFFEE;font-weight:bold}
.footer{color:#FFFFEE;font-size:8pt}
.info,.title{background-color:#002F90}
.outter{background-color:#350682}
.cell{background-color:#9B9D9A}
FONT.search{color:#FFFFFF}
FONT.notice{color:#FFFFFF}
.retable{background-color:#FFFFFF}
.rcontent{background-color:#F0F0F0}
FONT.small{font-size:7pt}
.style1 {color: #0000FF}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
//==========================================================================
String CountLink = request.getContextPath()+"/cms/counter/ViewInfo.asp"; //查看统计结果的连接。
String ImageLink = request.getContextPath()+"/cms/counter"; //图片地址
%>
<table width="576" border="0" cellpadding="0" cellspacing="0" align="center" height="48">
<tr>
<td align="center"><font color="#000000">今日: <%=today%><img src="<%=ImageLink%>/theme/default/vstatb.gif">
全部: <%=AllCount%><img src="<%=ImageLink%>/theme/default/hstatt.gif"> 最高:
<%=DayMax%><img src="<%=ImageLink%>/theme/default/vstatg.gif"> 日均: <%=Avera%>
<%
//===========================================================================
String ScriptName = request.getRequestURL().toString();
//===========================================================================
String path = "bc";
try {
ResultSet MyCount = conn.executeQuery("Select * From bc");
if ( conn.getRows()>0)
{
%>
<a href="showlast.jsp">最后20位访问</a></font></td>
</tr>
</table>
<table class=p9 width="576" align="center" border="0" cellpadding="0" cellspacing="0">
<tr class=info>
<td align=right colspan=2><font class=strong>访问者 浏览器 统计</font></td>
</tr>
<%
int counttotal = 0;
int todaystotal = 0;
int countwidth = 0;
int todayswidth = 0;
while (MyCount.next())
{
counttotal = MyCount.getInt("count") + counttotal;
todaystotal = MyCount.getInt("todays") + todaystotal;
if (countwidth < MyCount.getInt("count"))
countwidth = MyCount.getInt("count");
if (todayswidth < MyCount.getInt("todays"))
todayswidth = MyCount.getInt("todays");
}
MyCount.beforeFirst();
int dpct = 0;
int tpct = 0;
int widthd = 0;
int widtht = 0;
while (MyCount.next())
{
dpct = (int)Math.round((double)MyCount.getInt("todays")/todaystotal*100);
tpct = (int)Math.round((double)MyCount.getInt("count")/counttotal*100);
widthd = dpct*3;
widtht = tpct*3;
%>
<tr class=rcontent>
<td height="39"><nobr><%=MyCount.getString(path)%></nobr></td>
<td height="39"><nobr><img src="<%=ImageLink%>/theme/default/vstatb.gif" width="<%=widthd%>" height=10><%=Percent(MyCount.getInt("todays"),todaystotal)%>
(<%=MyCount.getInt("todays")%>)<nobr><br>
<nobr><img src="<%=ImageLink%>/theme/default/hstatt.gif" width="<%=widtht%>" height=10><%=Percent(MyCount.getInt("count"),counttotal)%>
(<%=MyCount.getInt("count")%>)</nobr></td>
</tr>
<%
}%>
</table>
<%
}
MyCount.close();
}
catch (java.sql.SQLException e)
{}
catch (java.io.IOException e)
{}
path = "os";
try {
ResultSet MyCount = conn.executeQuery("Select * From os");
if ( conn.getRows()>0)
{
%>
<table class=p9 width="576" align="center" border="0" cellspacing="0" cellpadding="0">
<tr class=info>
<td align=right colspan=2><font class=strong>访问者 操作系统 统计</font></td>
</tr>
<%
int counttotal = 0;
int todaystotal = 0;
int countwidth = 0;
int todayswidth = 0;
while (MyCount.next())
{
counttotal = MyCount.getInt("count") + counttotal;
todaystotal = MyCount.getInt("todays") + todaystotal;
if (countwidth < MyCount.getInt("count"))
countwidth = MyCount.getInt("count");
if (todayswidth < MyCount.getInt("todays"))
todayswidth = MyCount.getInt("todays");
}
MyCount.beforeFirst();
int dpct = 0;
int tpct = 0;
int widthd = 0;
int widtht = 0;
while (MyCount.next())
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -