⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 counter.jsp

📁 一款由8人组成的团队
💻 JSP
📖 第 1 页 / 共 2 页
字号:
                        MyCount.updateInt(3,MyCountDay);
                MyCount.updateInt(1,MyCount.getInt("AllCount")+1);
                MyCount.updateInt(2,MyCountDay);
				MyCount.updateDate(5,new java.sql.Date(cal.getTimeInMillis()));
				MyCount.updateRow();
		*/		
				int dayMax = MyCount.getInt("DayMax");
				if (dayMax < MyCountDay)
					dayMax = MyCountDay;
				StrSQL = "update Count set AllCount=AllCount+1,ToDayCount="+MyCountDay+",DayMax="+dayMax+",LogDate=NOW()";
				conn.executeUpdate(StrSQL);
        }
		if (MyCount!=null) {
			try { MyCount.close(); } catch (Exception e) {}
			MyCount = null;
		}

//===================================================================
        int Hourn = cal.get(cal.HOUR_OF_DAY);
		boolean ToDaysCount = false;
        StrSQL = "Select ID,DayCount."+Hourn+" FROM DayCount Where ID = " + DayDate;
        MyCount = conn.executeQuery(StrSQL);
        if (!MyCount.next())
		{
                /*
				MyCount.moveToInsertRow();
                MyCount.updateInt(1,Integer.parseInt(DayDate));
                MyCount.updateInt(2,1);
				MyCount.insertRow();
				*/
				StrSQL = "insert DayCount (ID, DayCount."+Hourn+") values ("+DayDate+",1)";
				conn.executeUpdate(StrSQL);
                ToDaysCount = false;
		}
        else
		{
                // MyCount.updateInt(2,MyCount.getInt(2)+1);
                // ToDaysCount    = true;
				// MyCount.updateRow();
				int dayCount = MyCount.getInt(2);
				StrSQL = "update DayCount set DayCount."+Hourn+"="+(dayCount+1) + " where ID="+DayDate;
				conn.executeUpdate(StrSQL);
        }
		if (MyCount!=null) {
			try { MyCount.close(); } catch (Exception e) {}
			MyCount = null;
		}

//===================================================================
        int Monn=cal.get(cal.MONTH)+1;
        StrSQL = "Select ID,"+Monn+" FROM YearCount where ID = " + YeaDate;

        MyCount = conn.executeQuery(StrSQL);
        if (!MyCount.next())
		{
                /*
				MyCount.moveToInsertRow();
                MyCount.updateInt(1,Integer.parseInt(YeaDate));
                MyCount.updateInt(2,1);
				MyCount.insertRow();
				*/
				StrSQL = "insert YearCount (ID,YearCount."+Monn+") values ("+YeaDate+",1)";
				conn.executeUpdate(StrSQL);
        }
		else
		{
				// MyCount.updateInt(2,MyCount.getInt(2)+1);
				// MyCount.updateRow();
				StrSQL = "update YearCount set YearCount."+Monn+"=YearCount."+Monn+"+1 where ID="+YeaDate;
				conn.executeUpdate(StrSQL);
        }
		if (MyCount!=null) {
			try { MyCount.close(); } catch (Exception e) {}
			MyCount = null;
		}

		String BC="",OS="";
		String[] Agt;
//===================================================================
        String aAgt = request.getHeader("User-Agent");
//===================================================================
        if (aAgt.indexOf("Mozilla")!=-1)
		{
                   if (aAgt.indexOf("MSIE")!=-1)
				   {
                         if (aAgt.indexOf("4.90")!=-1)
                             aAgt = aAgt.replaceAll("98","Me");
                         Agt = aAgt.split(";");
                         BC  = Agt[0].trim();
                         OS  = Agt[1].trim();
			       }
                   if (aAgt.indexOf("Opera")!=-1)
				   {
							   BC = "Opera" + aAgt.substring(aAgt.indexOf(")")+1);
							   OS = aAgt.substring(aAgt.indexOf(";")+2);
							   OS = OS.substring(0,OS.indexOf(";")+2);
							   OS = OS.substring(0,OS.indexOf(")"));
                   }
					else
					{
                           if (aAgt.indexOf("[en]")!=-1 || aAgt.indexOf("Gold")!=-1)
						   {
								 BC = aAgt.substring(aAgt.indexOf("/"));
								 BC = "Netscape" + " " + BC.substring(0,BC.indexOf(" "));
								 OS = aAgt.substring(aAgt.indexOf("(")+1);
								 OS = OS.substring(1,OS.indexOf(";")-1);
								 OS = OS.replaceAll("win","windows");
                           }
						   else
						   {
                                 BC = "Unknown";
                                 OS = "Unknown";
                           }
                   }
	    }
        else
		{
                 BC = "Unknown";
                 OS = "Unknown";
		}
        BC = BC.replaceAll("MSIE","Internet Explorer");
        OS = fchar.replace(OS,")","");
        OS = OS.replaceAll("NT 5.0","2000");
        OS = OS.replaceAll("4.10","98");
        OS = OS.replaceAll("4.90","Me");
//=========================================================
        addinfo("bc",BC,ToDaysCount);
        addinfo("os",OS,ToDaysCount);
//=========================================================
        String IPaddress = request.getRemoteAddr();
//=========================================================
		StrSQL = "Select bc,OS,IP,Date FROM lastly";
        MyCount = conn.executeQuery(StrSQL);
        if (conn.getRows()>20)
		{
                // MyCount.first();
                // MyCount.deleteRow();
				if (MyCount.next()) {
					String IP = MyCount.getString(3);
					String date = MyCount.getString(4);
					StrSQL = "delete from lastly where IP=" + fchar.sqlstr(IP) + " and date=" + fchar.sqlstr(date);
					conn.executeUpdate(StrSQL);
				}
        }
        // MyCount.moveToInsertRow();
        // MyCount.updateString(1,BC);
        // MyCount.updateString(2,OS);
		// MyCount.updateString(3,IPaddress);
        // MyCount.insertRow();
		StrSQL = "insert lastly (bc,OS,IP,Date) values("+fchar.sqlstr(BC)+","+fchar.sqlstr(OS)+","+fchar.sqlstr(IPaddress)+",NOW())";
		conn.executeUpdate(StrSQL);
		
		if (MyCount!=null) {
			try { MyCount.close(); } catch (Exception e) {}
			MyCount = null;
		}
		
	//Session("ASPCounter") = True
	//=========================================================
	String Counter = "";
	StrSQL = "Select PageCount,AllCount FROM Count";
	MyCount = conn.executeQuery(StrSQL);
	if (MyCount!=null && MyCount.next())
	{
		// MyCount.updateInt(1,MyCount.getInt(1)+1);
		// MyCount.updateRow();
		if (!CountMode)
			Counter = MyCount.getString("PageCount");
		else
			Counter = MyCount.getString("AllCount");
		StrSQL = "update Count set PageCount=PageCount+1";
		conn.executeUpdate(StrSQL);
	}

	if (CountView)
	{
			//=========================================================
			int CountLength=Counter.length();
			String Style = fchar.getNullString(request.getParameter("style"));
			//=========================================================
			String PicView="";
	
			if (CountLength < CountSize)
			{
				int CountToAdd = CountSize - CountLength;
				for (int i = 1; i<=CountToAdd; i++)
				{
					  if (!Style.equals(""))
						   PicView = PicView + "<IMG SRC=" + ImageLink + "/" + Style + "/0.gif border=0>";
					  else
						   PicView = PicView + "0";
				}
			}
	
			for (int i = 0; i<CountLength; i++)
			{
				 if (!Style.equals(""))
					  PicView = PicView + "<IMG SRC=" + ImageLink + "/" + Style + "/" + Counter.substring(i,i+1) + ".gif border=0>";
				 else
					  PicView = PicView + "" + Counter.substring(i,i+1) + "";
			}
			out.println("document.write('<NOBR><a href=" + CountLink + " title=?? target=_blank>" + PicView + "</A></NOBR>');");
	}
}
catch (Exception e) {
	out.print(e.getMessage() + "<BR>" + StrSQL);
    e.printStackTrace();
}
finally {
	if (MyCount!=null) {
		try { MyCount.close(); } catch (SQLException e) {}
		MyCount = null;
	}
}
if (conn!=null) {
	conn.close();
	conn = null;
}
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -