📄 view.jsp.bak
字号:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*,Db_sql"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.util.Date"%>
<%
String strSql;
Db_sql db = null;
Hashtable countresult = new Hashtable();
String typename = "";
String username = "";
String email = "";
String webname = "";
String url = "";
String sTemp = "";
int iCount = 0;
int perdayhits = 0;
int pdayhits = 0;
int iTemp = 0;
int torder = 0;
int order = 0;
//int iUid = 0;
String iUid = "";
Date dTemp = null;
Hashtable[] client = new Hashtable[25];
try {
iUid = request.getParameter("uid");
db = new Db_sql("10.1.1.202","1521","oracle8","home4u","home4u");
// db = new Db_sql("202.84.10.191","7137","appdb","liu","liujie8");
strSql = " update stat set avghits=round(totalhits/(round(SYSDATE-starttime)+1)) ";
db.query(strSql);
strSql = " select id,puid,starttime,totalhits,sitetype,maxhits,todayhits, ";
strSql += " round(SYSDATE-starttime)+1 as days, avghits from stat ";
strSql += " where puid= '" + iUid + "'";
db.query(strSql);
if (db.next())
{
countresult.put("id",new Integer(db.getInt("id")));
countresult.put("puid",db.getString("puid"));
countresult.put("starttime",db.getDate("starttime"));
countresult.put("totalhits",new Integer(db.getInt("totalhits")));
countresult.put("sitetype",db.getString("sitetype"));
countresult.put("todayhits",new Integer(db.getInt("todayhits")));
countresult.put("maxhits",new Integer(db.getInt("maxhits")));
countresult.put("avghits",new Integer(db.getInt("avghits")));
countresult.put("days",new Integer(db.getInt("days")));
//-------------取得站点类型-------------------------
typename = (String)countresult.get("sitetype");
//------------计算平均每天浏览量----------------------
iTemp = ((Integer)countresult.get("days")).intValue();
if (iTemp != 0)
perdayhits = ((Integer)countresult.get("totalhits")).intValue()/iTemp;
else
perdayhits = ((Integer)countresult.get("todayhits")).intValue();
//-----------得到用户的邮件和名字 站名 url----------------------
strSql = " select username,email,title ";
strSql += " from userinfo where username= '" + iUid + "'";
db.query(strSql);
if (db.next())
{
username = db.getString("username");
email = db.getString("email");
webname = db.getString("title");
url = "http://" + iUid + ".at.china.com";
}
//-----------计算在同类网站中目前平均排名-----------------
strSql = "select count(*) as above_count from stat where avghits>";
strSql += (Integer)countresult.get("avghits");
strSql += " and sitetype='" + (String)countresult.get("sitetype") + "'";
db.query(strSql);
db.next();
torder = db.getInt("above_count") + 1;
//----------计算在所有网站中平均排名--------------------
strSql = "select count(*) as above_count from stat where avghits>";
strSql += (Integer)countresult.get("avghits");
db.query(strSql);
db.next();
order = db.getInt("above_count") + 1;
//-----------预计本日浏览人数-----------------------
dTemp = new Date();
iTemp = ((Integer)countresult.get("todayhits")).intValue();
if ((dTemp.getHours()*60 + dTemp.getMinutes()) != 0)
{
pdayhits = (new Float(((float)iTemp/(dTemp.getHours()*60 + dTemp.getMinutes())) *24*60)).intValue();
}
else
{
pdayhits = perdayhits;
}
//-----------读取最近25位访问者--------------------
strSql = "select id,puid,ip,browser,os,ip,to_char(thedate,'yyyy-mm-dd') as thedate, ";
strSql += " to_char(thedate,'hh24:mi:ss') as thetime from statdetail ";
strSql += "where puid='" + iUid + "' order by thedate desc";
db.query(strSql);
for (iCount = 0;db.next();iCount++)
{
if (iCount >= 25) break;
client[iCount] = new Hashtable();
sTemp = db.getString("thedate");
client[iCount].put("thedate",sTemp);
sTemp = db.getString("thetime");
client[iCount].put("thetime",sTemp);
client[iCount].put("ip",db.getString("ip"));
client[iCount].put("browser",db.getString("browser"));
client[iCount].put("os",db.getString("os"));
}
}
} catch(Exception e)
{
out.println(e);
} finally
{
try { db.close(); } catch(Exception e) {}
}
%>
<html>
<head>
<title>中华网---个人主页统计</title>
<style type="text/css">
<!--
body.t{ font-family: "宋体", "Arial", "Times New Roman"; font-size: 9pt;
line-height: 150%; letter-spacing: 1px}
.tt3{ font-family: "!宋体", "!Arial", "!Times New Roman"; font-size:11pt;
line-height: 130%; color: #000000;}
a:hover {color:red;text-decoration:underline}
-->
</style></head>
<body class="tt3">
<div align="center"><center>
<table border="0" width="513" bgcolor="#FCFDDB" cellspacing="0"
cellpadding="2" class="tt3">
<tr>
<td width="18" height="86"></td>
<td width="462" height="86" valign="top"><p align="center"><img src="logohome.gif"
width="303" height="84" alt="logohome.gif (6077 bytes)"></td>
<td width="29" height="86"></td>
</tr>
<tr>
<td width="18" height="28"></td>
<td width="511" height="28" valign="top">
<p align="center">
<a href=<%="\"hourstat.jsp?uid=" + iUid + "\""%>>小时统计</a>
<a href=<%="\"daystat.jsp?uid=" + iUid + "\""%>>日统计</a>
<a href=<%="\"weekstat.jsp?uid=" + iUid + "\""%>>周统计</a>
<a href=<%="\"monthstat.jsp?uid=" + iUid + "\""%>>月统计</a>
<a href=<%="\"purl.jsp?uid=" + iUid + "\""%>>来路显示</a> </font></td>
<td width="29" height="28"></td>
</tr>
<tr>
<td width="18" height="28"></td>
<td width="511" height="28" valign="top">
<p align="center">
<%
sTemp = "站名:<a href=\"" + url + "\">";
sTemp += webname + "</a> ";
sTemp += "站长:" + "<a href=\"mainto:" + email + "\">";
sTemp += username + "</a>";
out.println(sTemp);
%>
<td width="29" height="28"></td>
</tr>
<tr>
<td width="18" rowspan="2"></td>
<td width="462" valign="top"><table border="0" cellPadding="2" width="100%"
cellspaccing="2">
<TBODY>
<tr>
<td><table class="tt3" border="1" borderColor="#336600" cellPadding="0" cellSpacing="0" width="100%">
<TBODY>
<tr>
<td><table class="tt3" border="0" cellPadding="3" cellSpacing="0" width="100%">
<TBODY>
<tr bgColor="#336600">
<td align="middle" bgColor="#336600" colSpan="2" width="100%"><font color="#ffffff">综
合 数 据</font></td>
</tr>
<tr bgColor="#cccccc">
<td align="left" width="60%"><p class="sureyeah">开始统计日期 </td>
<td align="right" width="40%"><font color="#336699" >
<%
try {
out.println((Date)countresult.get("starttime"));
} catch (Exception e) { out.println(e); }
%>
</font></td>
</tr>
<tr bgColor="#ffffff">
<td align="left" width="60%">总统计天数</td>
<td align="right" width="40%"><font color="#336699" ><% out.println((Integer)countresult.get("days")); %></font></td>
</tr>
<tr bgColor="#cccccc">
<td align="left" width="60%">总浏览人数</td>
<td align="middle" width="40%"><p align="right"><font color="#336699" ><% out.println((Integer)countresult.get("totalhits")); %></font></td>
</tr>
<tr bgColor="#ffffff">
<td align="left" width="60%">平均每天访问人数</td>
<td align="right" width="40%"><font color="#336699" ><% out.println(perdayhits); %></font></td>
</tr>
<tr bgColor="#cccccc">
<td align="left" width="60%">站点性质</td>
<td align="right" width="40%"><font color="#336699" ><% out.println(typename); %></font></td>
</tr>
<tr bgColor="#cccccc">
<td align="left" width="60%">目前同类站点中平均排名</td>
<td align="right" width="40%"><font color="#336699" >第 <% out.println(torder); %> 名</font></td>
</tr>
<tr bgColor="#ffffff">
<td align="left" width="60%">目前总平均排名</td>
<td align="right" width="40%"><font color="#336699" >第 <% out.println(order); %> 名</font></td>
</tr>
<tr bgColor="#ffffff">
<td align="left" width="60%">今日总浏览人数</td>
<td align="right" width="40%"><font color="#336699" ><% out.println((Integer)countresult.get("todayhits")); %></font></td>
</tr>
<tr bgColor="#cccccc">
<td align="left" width="60%">预计本日浏览人数</td>
<td align="right" width="40%"><font color="#336699" ><% out.println(pdayhits); %></font></td>
</tr>
<tr bgColor="#ffffff">
<td align="left" width="60%">最高一天浏览量</td>
<td align="right" width="40%"><font color="#336699" ><% out.println((Integer)countresult.get("maxhits")); %></font></td>
</tr>
</TBODY>
</table>
</td>
</tr>
</TBODY>
</table>
</td>
</tr>
</table>
</td>
<td width="29" height="60" rowspan="2"></td>
</tr>
<tr>
<td width="462"><table class="tt3" border="1" borderColor="#336600" cellPadding="0"
cellSpacing="0" width="100%">
<TBODY>
<tr>
<td><table class="tt3" border="0" cellPadding="1" cellSpacing="0" height="155" width="100%">
<TBODY>
<tr>
<td colspan="6" align="middle" bgColor="#336600" colSpan="5" width="100%"><font
color="#ffffff"><% out.println("最 后 " + iCount + " 位 访 问 者"); %></font></td>
</tr>
<tr bgColor="#cccccc">
<td align="middle">日期</td>
<td align="left"><p align="center">时间</td>
<td align="left"><p align="enter">访客IP</td>
<td align="left"><p align="center">浏览器</td>
<td align="right"><p align="center">操作系统</td>
</tr>
<% int i=0; %>
<% while(i<iCount) {%>
<%try {%>
<tr bgColor="#ffffff">
<td align="middle" noWrap ><% out.println((String)client[i].get("thedate")); %></td>
<td align="middle" noWrap ><% out.println((String)client[i].get("thetime")); %></td>
<td align="left" noWrap ><p align="center"><% out.println((String)client[i].get("ip")); %></td>
<td align="left" noWrap ><p align="center"><font color="#000000"><% out.println((String)client[i].get("browser")); %></font></td>
<td align="left" noWrap ><p align="center"><font color="#336699"><% out.println((String)client[i].get("os")); %></font></td>
<%} catch (Exception e) { out.println(e); } %>
</tr>
<% i++;
} %>
</TBODY>
</table>
</td>
</tr>
</TBODY>
</table>
</td>
</tr>
<tr>
<td height="28" width="18"></td>
<td height="28" width="462"></td>
<td height="28" width="29"></td>
</tr>
</table>
</center></div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -