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

📄 pointlanmu.java

📁 JAVA邮件系统
💻 JAVA
字号:
/* 
 *
 */
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import java.util .Date ;
import javax.servlet.http.*;
/**
 * 
 *
 * @author Zhu Ke Jun
 */
public class PointLanmu extends HttpServlet{
   public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
        
		HtmlOut htmlOut = new HtmlOut (response);
    	//身份验证:
		// 得到名字和口令
		String name = CommonMethods.getParameterValue (request,"Name");
		String pass = CommonMethods.getParameterValue (request,"Password");
		if(name!=null&&pass!=null){
			htmlOut.addCookie ("username",name);
			htmlOut.addCookie ("password",pass);
		}
		else{//other we get it by cookie;
			name = CommonMethods.GetUserName(request);
			pass = CommonMethods.GetUserPass(request);
		}
		Person p=new Person();
		p.setName (name);
		if( p.getName ()==null || (!p.checkPassword(pass))
			||(!p.IsSuperMan ()&&!p.IsManager ()) )
		{
	    	htmlOut.setErrorID (htmlOut.SHOW_SIMPLE_MESSAGE ,"",
								"请先登录!","/manage/");
			htmlOut.outHtml();
			return;
		}

		/*------------------------------------------*/
		String sFile = CommonMethods.sLogPath ;//文件
    sFile=sFile+"access.log"  ;
		File file;
		file=new File(sFile);
		 FileReader freader;//读取文件
 		try
 		{
  			freader = new FileReader(sFile);
 		}catch(FileNotFoundException e)
 		{
			System.out .print ("file can not read1");
 			return ;
 		}
		BufferedReader in= new BufferedReader(freader);
		boolean flag=false;
		int lanmupoint[];
		lanmupoint=new int [18];
		flag=true;
		AnalyzeString analyze;
		analyze=new AnalyzeString ();
		int j=0;
		for(j=0;j<18;j++)
		{
			lanmupoint[j]=0;
		}
		String templine="",page,time,ip;
		/*------------------------------------------*/
		//按栏目对访问人数统计
		String lanmu[][];
		lanmu=new String[18][2];
		lanmu[0][0]="/b/Default.htm";lanmu[0][1]="主页";
		lanmu[1][0]="/b/gsdt/Default.htm";lanmu[1][1]="公司动态";
		lanmu[2][0]="/b/gscp/Default.htm";lanmu[2][1]="公司产品";
		lanmu[3][0]="/b/jrzx/Default.htm";lanmu[3][1]="金融中心";
		lanmu[4][0]="/b/khmy/Default.htm";lanmu[4][1]="客户满意中心";
		lanmu[5][0]="/sms/home.htm";lanmu[5][1]="短信息点播";
		lanmu[6][0]="/Login";lanmu[6][1]="社区";
		lanmu[7][0]="/EditChannel?channel=weather";lanmu[7][1]="天气";
		lanmu[8][0]="/CardServlet";lanmu[8][1]="名片";
		lanmu[9][0]="/BookmarkServlet";lanmu[9][1]="书签";
		lanmu[10][0]="/FolderServlet";lanmu[10][1]="文件夹";
		lanmu[11][0]="/DateShowDay";lanmu[11][1]="日历";
		lanmu[12][0]="/Dictionary";lanmu[12][1]="字典";
		lanmu[13][0]="/EditChannel?channel=train";lanmu[13][1]="列车提醒";
		lanmu[14][0]="/EditChannel?channel=Hb";lanmu[14][1]="航班";
		lanmu[15][0]="/EditChannel?channel=wh";lanmu[15][1]="外汇";
		lanmu[16][0]="/EditChannel?channel=stock";lanmu[16][1]="股票";
		lanmu[17][0]="/b/wxcp/Default.htm";lanmu[17][1]="无线产品";
		
		
		while(flag)
		{   
			try{
					templine=in.readLine(); 
				}catch(Exception e){}
				if(templine==null)
				{flag=false;
				 System.out .println ("ok");
				 break;}
				analyze.getstring (templine);
				page=analyze.getpage ();
				time=analyze.gettime ();
				ip=analyze.getip ();
				//out.println(analyze.getpage()+"<br>");
				if(page.compareTo ("null")!=0&&time.compareTo ("null")!=0&&ip.compareTo ("null")!=0)
				for(int k=0;k<18;k++)
				{
					if(page.indexOf (lanmu[k][0])!=-1)
					{
						lanmupoint[k]=lanmupoint[k]+1;
						break;
					}
				}
		}
		
		try{
			freader.close ();
			in.close ();
		}catch(Exception e){}
		//所有栏目的访问总数
		double allpoint=0;
		for(j=0;j<18;j++)
		{
			allpoint=allpoint+lanmupoint[j];
		}
	
		//摸版替换
		TemplateList tempList = CommonMethods.getpointlanmuTemplate();
		SingleTemplate st;
		st = tempList.searchTemplate("ROOT");
		if(st==null){
			htmlOut.setErrorID (htmlOut.SINGLE_TEMPLATE_NOTFIND ,
								"","模板错误"
								,"Login");
			htmlOut.outHtml ();
			return ;
		}
		int nKey = st.getKeyNum ();
		String sKey ;
		for(int i=0;i<nKey;i++){
			htmlOut.addString (st.getStringAt (i));
			sKey = st.getKeyAt (i);
			if( sKey .compareTo("cgi-path")==0 )
				htmlOut.addString (CommonMethods.sHostNameCGI);
			if( sKey.compareTo("内容")==0 )
				makeContents(tempList,htmlOut,lanmupoint,lanmu,allpoint);
		}
		htmlOut.addString(st.getEndString());
		htmlOut.outHtml ();
	}
	 //时段列表内容
	public void makeContents(TemplateList tempList,HtmlOut desHtml,int lanmupoint[],String lanmu[][],double allpoint)
	{
		SingleTemplate st0,st1;
	   	st0 = tempList.searchTemplate("列表");
		if(st0==null)
			return;
    	st1 = tempList.searchTemplate("单支");
		if(st1==null)
			return;
		
	   	int i1,i2;
	   	for(i1=0;i1<st0.getKeyNum();i1++)
	   	    {
			
	   	    desHtml.addString(st0.getStringAt(i1));
			if(st0.getKeyAt(i1).compareTo("cgi-path")==0){
			desHtml.addString(CommonMethods.sHostNameCGI);}
			
	   	    if(st0.getKeyAt(i1).compareTo("全部")==0)
	   	    {
			   for(int i=0;i<18;i++)
   				  {
				  
   				   for(i2=0;i2<st1.getKeyNum();i2++)
   				    {
					
   						desHtml.addString(st1.getStringAt(i2));
						if(st1.getKeyAt(i2).compareTo("cgi-path")==0){
						desHtml.addString(CommonMethods.sHostNameCGI);}
   				    	if(st1.getKeyAt(i2).compareTo("栏目")==0)
   				    	desHtml.addString(lanmu[i][1]);
   				    	if(st1.getKeyAt(i2).compareTo("访问人数")==0)
   				    	desHtml.addString(String.valueOf(lanmupoint[i]));
   				    	if(st1.getKeyAt(i2).compareTo("比例")==0)
						{
							if(allpoint==0)
								desHtml.addString ("0");
							else 
   				    		desHtml.addString(CommonMethods.FormatDouble (lanmupoint[i]*100/allpoint,2));
						}
   				    	if(st1.getKeyAt(i2).compareTo("统计图")==0)
						{
							if(allpoint==0)
								desHtml.addString ("0");
							else 
   				    	desHtml.addString(CommonMethods.FormatDouble (lanmupoint[i]*100*10/allpoint,0).substring (0,CommonMethods.FormatDouble (lanmupoint[i]*100*10/allpoint,0).indexOf(".")));
						}
   				     }
   				    desHtml.addString(st1.getEndString());
   				   }
	   	    }
	   	    }
	   desHtml.addString(st0.getEndString());
	
	 }
    public void doPost(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
		 doGet(request,response);
		 
	}
}

⌨️ 快捷键说明

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