Ejemplo n.º 1
0
int ltdeljjr(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
    char sqlBuf[1048];
    char caMsg[256];
    char *dbUser;
	  char *dbPass;
	  char *dbName;
	  dbName=_ltPubInfo->_dbname;
	  dbUser=_ltPubInfo->_dbuser;
	  dbPass=_ltPubInfo->_dbpass;
	  G_DbCon=ltDbConnect(dbUser,dbPass,dbName);
	  if(G_DbCon==NULL){
							ltMsgPk->msgpktype=1;
							lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html\n","lthtml",LT_TYPE_STRING,"");
							ltMsgFree(ltMsgPk);			
							return 0;
	  }
    sprintf(sqlBuf,"delete from nasjjr where jjrid in (%s) ",
    ltMsgGetVar_s(ltMsgPk,"checkbox"));
    ltDbExecSql(G_DbCon,sqlBuf); 
               
	  _ltPubInfo->_jjrtimelist[atol(ltMsgGetVar_s(ltMsgPk,"checkbox"))].jjrid=0;
	  strcpy(_ltPubInfo->_jjrtimelist[atol(ltMsgGetVar_s(ltMsgPk,"checkbox"))].jjrname,"");
	  strcpy(_ltPubInfo->_jjrtimelist[atol(ltMsgGetVar_s(ltMsgPk,"checkbox"))].jjrdesc,"");
	  strcpy(_ltPubInfo->_jjrtimelist[atol(ltMsgGetVar_s(ltMsgPk,"checkbox"))].jjrtime,""); 
    snprintf(caMsg,255,"%s","delete nasjjr success.");
	  logWrite(ltMsgPk,caMsg,3);
	  ltDbClose(G_DbCon);
    ltjjrinfolist(confd,ltMsgPk,lt_MMHead);
    return 0;
}
Ejemplo n.º 2
0
//添加服务策略页面
int showRuleSrvSimp(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
	 //数据库连接
		  char *dbUser;
		  char *dbPass;
		  char *dbName;
		  dbName=_ltPubInfo->_dbname;
			dbUser=_ltPubInfo->_dbuser;
			dbPass=_ltPubInfo->_dbpass;
			G_DbCon=ltDbConnect(dbUser,dbPass,dbName);
			if(G_DbCon!=NULL){
				//printf("db connect ok\n");
			}else{
				fprintf(stderr,"db connect error\n");
			}
	 char sqlBuf[64];
   ltDbHeadPtr dbPtr;
   ltTablePtr tablePtr;
   LT_DBROW tempRow;
	 ltDbCursor *tempCursor;
	 dbPtr=lt_dbinit();
   lt_db_htmlpage(dbPtr,"utf-8");
	 tablePtr=lt_dbput_table(dbPtr,"qoslist");
	 lt_dbput_rootvars(dbPtr,1,"ruleid",ltMsgGetVar_s(ltMsgPk,"sid"));
	 memset(sqlBuf,0,sizeof(sqlBuf));
	 sprintf(sqlBuf,"select sid,qosname from msaqos order by sid asc");
	 tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
	 if(tempCursor!=NULL){
				tempRow=ltDbFetchRow(tempCursor);
				while(tempRow!=NULL){
//						memset(qossel,0,sizeof(qossel));
//						if(atoi(tempRow[0])==myqosid){
//								sprintf(qossel,"%s","selected");
//						}
						lt_dbput_recordvars(tablePtr,2,
						  "qosid",LT_TYPE_STRING,tempRow[0],
							"qosname",LT_TYPE_STRING,tempRow[1]);
					  tempRow=ltDbFetchRow(tempCursor);
				}
				ltDbCloseCursor(tempCursor);
	 }
	 ltDbClose(G_DbCon);
   lt_dbput_rootvars(dbPtr,1,"ruleid",ltMsgGetVar_s(ltMsgPk,"ruleid"));
   lt_dbput_rootvars(dbPtr,1,"sid",ltMsgGetVar_s(ltMsgPk,"sid"));
   lt_dbput_rootvars(dbPtr,1,"rulesrv","0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
	 lt_dbput_rootvars(dbPtr,1,"function","addRuleSrv");
   ltMsgPk->msgpktype=1;
   lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msa/htmlplt/rule/ruleSrvAddSimp.htm",dbPtr->head,0);
   ltMsgFree(ltMsgPk);
   lt_dbfree(dbPtr);
   return 0;
}
Ejemplo n.º 3
0
/*初始化服务特征*/
int ltreseturlsort(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
	  char *casrvid;
 		char *caflag;
	  
	  casrvid=ltMsgGetVar_s(ltMsgPk,"srvid");
		caflag=ltMsgGetVar_s(ltMsgPk,"flag");

    if(atoi(caflag)==1){
		  char pFile[512];
		  char caCmdCon[2048];
		  
		  //初始服务特征
		  memset(pFile,0,sizeof(pFile));
		  sprintf(pFile,"/etc/msa/msa/srvlist/srvdefine/%s",casrvid);
		   
		  memset(caCmdCon,0,sizeof(caCmdCon)); 
			sprintf(caCmdCon,"/bin/rm -rf %s",pFile);
		  system(caCmdCon);
		  
		  //初始IP列表
		  memset(pFile,0,sizeof(pFile));
		  sprintf(pFile,"/etc/msa/msa/srvlist/diplist/%s",casrvid);
		   
		  memset(caCmdCon,0,sizeof(caCmdCon)); 
			sprintf(caCmdCon,"/bin/rm -rf %s",pFile);
		  system(caCmdCon);
		  
		  //初始域名列表
		  memset(pFile,0,sizeof(pFile));
		  sprintf(pFile,"/etc/msa/msa/srvlist/urllist/%s",casrvid);
		   
		  memset(caCmdCon,0,sizeof(caCmdCon)); 
			sprintf(caCmdCon,"/bin/rm -rf %s",pFile);
		  system(caCmdCon);
	    
		  ltMsgPk->msgpktype=1;
	    lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\n","lthtml",LT_TYPE_STRING,"0");
	    ltMsgFree(ltMsgPk);
	    return 0;
		}else{
		  ltMsgPk->msgpktype=1;
	    lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\n","lthtml",LT_TYPE_STRING,"1");
	    ltMsgFree(ltMsgPk);
	    return 0;
		} 
}
Ejemplo n.º 4
0
/*加载服务修改页面*/
int ltupdateurlsort(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
   char *my_id;
	 char sqlBuf[2048];
   ltDbHeadPtr dbPtr;
   dbPtr=lt_dbinit();
   ltDbCursor *tempCursor;
   LT_DBROW   tempRow;
   
   char *dbUser;
	 char *dbPass;
	 char *dbName;
	 dbName=_ltPubInfo->_dbname;
	 dbUser=_ltPubInfo->_dbuser;
	 dbPass=_ltPubInfo->_dbpass;
	 G_DbCon=ltDbConnect(dbUser,dbPass,dbName);
	 if(G_DbCon==NULL)
	 {
			ltMsgPk->msgpktype=1;
			lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html\n","lthtml",LT_TYPE_STRING,"db error!");
			ltMsgFree(ltMsgPk);			
			return 0;
	 }
   my_id=ltMsgGetVar_s(ltMsgPk,"my_id");
   dbPtr=lt_dbinit();
   lt_db_htmlpage(dbPtr,"utf-8");
   if(my_id!=NULL){
		sprintf(sqlBuf,"select srvid,topsrvid,denytype,srvname,srvdesc,level from nassrv where srvid='%s'",my_id);
printf("sqlBuf:%s\n",sqlBuf);
			 tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
			 if(tempCursor!=NULL){
					 tempRow= ltDbFetchRow(tempCursor);
					 if(tempRow!=NULL){
						 char str[16];
						 
						 memset(str,0,sizeof(str));
						 sprintf(str,"denytype%ssel",tempRow[2]);
 						 lt_dbput_rootvars(dbPtr,1,str,"selected");//服务类型
 						 
						 lt_dbput_rootvars(dbPtr,1,"srvname",tempRow[3]);
						 lt_dbput_rootvars(dbPtr,1,"srvdesc",tempRow[4]);
						 
						 memset(str,0,sizeof(str));
						 sprintf(str,"level%ssel",tempRow[5]);
 						 lt_dbput_rootvars(dbPtr,1,str,"selected");//危害级别
 						 
						 lt_dbput_rootvars(dbPtr,1,"rid",tempRow[0]);
					 }
				 ltDbCloseCursor(tempCursor);
			 }
   }
   ltMsgPk->msgpktype=1;
   lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msa/htmlplt/manager/updateSrvPage.htm",dbPtr->head,0);
   ltMsgFree(ltMsgPk);
   ltDbClose(G_DbCon); 
   return 0;
}
Ejemplo n.º 5
0
/*
*显示输入的用户名和密码
*/
int ErrorTest(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead)
{
	char *name;
	char *password;
	char *rePass;
    char myre[1024];
	char caStr[2048];
	char sqlBuf[2048];
    name=ltMsgGetVar_s(ltMsgPk,"txtName");
    if(!name){
         name="";
   }
	password=ltMsgGetVar_s(ltMsgPk,"txtPass");
    if(!password){
         password="";
   }
   rePass=ltMsgGetVar_s(ltMsgPk,"txtRePass");
    if(!rePass){
         rePass="";
   }
   if(strcmp(password,rePass)!=0){
       ltMsgPk->msgpktype=1;
       lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\r\n",
				"lthtml",LT_TYPE_STRING,"error!");   
      ltMsgFree(ltMsgPk);
      return 0;	
   }

   sprintf(caStr,"insert into msasusertest values (3,'%s','%s')",name,password);
   ltDbExecSql(G_DbCon,sqlBuf); 

    //sprintf(caStr,"my name is:%s password:%s",name,password);
    sprintf(caStr,"%s is:%s password:%s",_ltPubInfo->pubMsgStr[0].conStr,name,password);
	ltMsgPk->msgpktype=1;
    lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\r\n",
				"lthtml",LT_TYPE_STRING,caStr);   
    ltMsgFree(ltMsgPk);
    return 0;
}
Ejemplo n.º 6
0
/*加载域名修改页面*/
int msaUpdateArea(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
   char *my_id;
   stralloc strTemp;
   strTemp.s=0;
   
   ltDbHeadPtr dbPtr;
   dbPtr=lt_dbinit();
   
   my_id=ltMsgGetVar_s(ltMsgPk,"my_id");
   dbPtr=lt_dbinit();
   lt_db_htmlpage(dbPtr,"utf-8");
   char pFile[512];
   if(my_id==NULL){
   		sprintf(pFile,"/etc/msa/msa/srvlist/urllist/1");
 	 }else{
   		sprintf(pFile,"/etc/msa/msa/srvlist/urllist/%s",my_id);
   }
   if(my_id!=NULL){
     int   match;
		 static char inbuf[4096];
		 int   fd;
		 
		 fd=open(pFile,O_RDONLY | O_NDELAY);
	   match=read(fd,inbuf,sizeof(inbuf));
		 int tt=access(pFile,0);//配置文件是否存在  不存在的话在页面上打印空
		 if(tt!=-1){
			 while(match){
			 	stralloc_catb(&strTemp,inbuf,match);
			 	match=read(fd,inbuf,sizeof(inbuf));
			 }
		   stralloc_0(&strTemp); 
	     lt_dbput_rootvars(dbPtr,1,"srvarea",strTemp.s);
     }else{
     	lt_dbput_rootvars(dbPtr,1,"srvarea","");
     }  
     lt_dbput_rootvars(dbPtr,1,"srvid",my_id);
   }
   ltMsgPk->msgpktype=1;
   lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msa/htmlplt/manager/updateSrvArea.htm",dbPtr->head,0);
   ltMsgFree(ltMsgPk);
   ltDbClose(G_DbCon); 
   return 0;
}
Ejemplo n.º 7
0
/*服务分类查询*/
int lturlsortlist(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
    char strBuf[1024];
    ltDbCursor *tempCursor;
    LT_DBROW tempRow;
    char caTmpp[512];
    long lRowNum,lStartRec,lSumRec,lCount,lNum;
    int k;
    char *topsrvid;
    stralloc strTemp;
    char *dbUser;
		char *dbPass;
		char *dbName;
		dbName=_ltPubInfo->_dbname;
		dbUser=_ltPubInfo->_dbuser;
		dbPass=_ltPubInfo->_dbpass;
		G_DbCon=ltDbConnect(dbUser,dbPass,dbName);
		if(G_DbCon==NULL){
				ltMsgPk->msgpktype=1;
				lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: application/json\n","lthtml",LT_TYPE_STRING,"db error!");
				ltMsgFree(ltMsgPk);			
				return 0;
		}
	  //ltDbClose(G_DbCon);
    topsrvid=ltMsgGetVar_s(ltMsgPk,"topsrvid");//一级服务
    lRowNum=50; /*每页的行数*/
    lSumRec=0;/*总行数*/
    lCount=0;
    lStartRec=0;
    lNum=0; /*该页剩余的行数*/
    if(ltMsgGetVar_s(ltMsgPk,"limit")){
    		lRowNum=atol(ltMsgGetVar_s(ltMsgPk,"limit"));
    }
    if(ltMsgGetVar_s(ltMsgPk,"start")){
    		lStartRec=atol(ltMsgGetVar_s(ltMsgPk,"start"));
    }
    if(strcmp(topsrvid,"-1")==0){
    	sprintf(strBuf,"select count(*) from nassrv");
    }else{
    	sprintf(strBuf,"select count(*) from nassrv where topsrvid=%s",topsrvid);
    }

		tempCursor=ltDbOpenCursor(G_DbCon,strBuf);
		if(tempCursor!=NULL){
				tempRow= ltDbFetchRow(tempCursor);
				if(tempRow!=NULL){
					lCount=atol(tempRow[0]);
				}
		}
		ltDbCloseCursor(tempCursor);

    strTemp.s=0;
    sprintf(caTmpp,"{\"totalCount\":\"%lu\",\"Results\":[",lCount);
    stralloc_cats(&strTemp,caTmpp);

   k=0;
   if(strcmp(topsrvid,"-1")==0){
   		sprintf(strBuf,"select srvid,topsrvid,denytype,srvname,srvdesc,level from nassrv order by srvid asc limit %lu offset %lu ",lRowNum,lStartRec);
   }else{
   		sprintf(strBuf,"select srvid,topsrvid,denytype,srvname,srvdesc,level from nassrv where topsrvid=%s order by srvid asc limit %lu offset %lu ",topsrvid,lRowNum,lStartRec);
   }
   printf("%s\n",strBuf);
   tempCursor=ltDbOpenCursor(G_DbCon,strBuf);
   if(tempCursor!=NULL){
			tempRow= ltDbFetchRow(tempCursor);
		  while(tempRow!=NULL){
		  	 if(k==0){
	     	  	sprintf(caTmpp,"{\"srvid\":\"%s\",\"topsrvname\":\"%s\",\"srvname\":\"%s\",\"srvdesc\":\"%s\",\"level\":\"%s\",\"denytype\":\"%s\"}",
	     	  	 tempRow[0],_ltPubInfo->topSrvName[atoi(tempRow[1])].srvname,tempRow[3],tempRow[4],tempRow[5],tempRow[2]);
	     	 		stralloc_cats(&strTemp,caTmpp);
	     	 }else{
	     	  	sprintf(caTmpp,",{\"srvid\":\"%s\",\"topsrvname\":\"%s\",\"srvname\":\"%s\",\"srvdesc\":\"%s\",\"level\":\"%s\",\"denytype\":\"%s\"}",
	     	  	 tempRow[0],_ltPubInfo->topSrvName[atoi(tempRow[1])].srvname,tempRow[3],tempRow[4],tempRow[5],tempRow[2]);
	     	 		stralloc_cats(&strTemp,caTmpp);
	     	 }
				tempRow= ltDbFetchRow(tempCursor);
				k++;
			}
     ltDbCloseCursor(tempCursor);
   }
	 stralloc_cats(&strTemp,"]}");
	 stralloc_0(&strTemp);
   ltMsgPk->msgpktype=1;
	 lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: application/json\n","lthtml",LT_TYPE_STRING,strTemp.s);
   ltDbClose(G_DbCon);
	 ltMsgFree(ltMsgPk);
	 return 0;
}
Ejemplo n.º 8
0
int msaalertset(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
   char *pFile="/etc/msa/msa/alert";
 	 char caCmdCon[128];
 	 
 	 char *mailalert,*smsalert;
   char *diskalert,*memalert,*mail,*telphone;
   char *newadminalert,*newrulealert,*delrulealert;
   char *outflowalert,*p2pflowalert;
	

	 //报警方式  邮件check   短信check  
	 //关闭Ping
	 if(ltMsgGetVar_s(ltMsgPk,"mailalert")){
	 	 mailalert=ltMsgGetVar_s(ltMsgPk,"mailalert");
	 }else{
	 	 mailalert="no";
	 }
   memset(caCmdCon,0,sizeof(caCmdCon));
   sprintf(caCmdCon,"echo 'mailalert=%s' > %s",mailalert,pFile);
   system(caCmdCon);
   
	 if(ltMsgGetVar_s(ltMsgPk,"smsalert")){
	 	 smsalert=ltMsgGetVar_s(ltMsgPk,"smsalert");
	 }else{
	   smsalert="no";	
	 }
   memset(caCmdCon,0,sizeof(caCmdCon));
   sprintf(caCmdCon,"echo 'smsalert=%s' >> %s",smsalert,pFile);
   system(caCmdCon);
	 //系统异常报警
	 if(ltMsgGetVar_s(ltMsgPk,"diskalert")){
	 	 diskalert=ltMsgGetVar_s(ltMsgPk,"diskalert");
	 }else{
	   diskalert="";	
	 }
   memset(caCmdCon,0,sizeof(caCmdCon));
   sprintf(caCmdCon,"echo 'diskalert=%s' >> %s",diskalert,pFile);
   system(caCmdCon);
   
	 if(ltMsgGetVar_s(ltMsgPk,"mail")){
	 	 mail=ltMsgGetVar_s(ltMsgPk,"mail");
	 }else{
	   mail="";
	 }
   memset(caCmdCon,0,sizeof(caCmdCon));
   sprintf(caCmdCon,"echo 'mail=%s' >> %s",mail,pFile);
   system(caCmdCon);
	 
	 if(ltMsgGetVar_s(ltMsgPk,"memalert")){
	 	 memalert=ltMsgGetVar_s(ltMsgPk,"memalert");
	 }else{
	   memalert="no";	
	 }
   memset(caCmdCon,0,sizeof(caCmdCon));
   sprintf(caCmdCon,"echo 'memalert=%s' >> %s",memalert,pFile);
   system(caCmdCon);
   
	 if(ltMsgGetVar_s(ltMsgPk,"telphone")){
	 	 telphone=ltMsgGetVar_s(ltMsgPk,"telphone");
	 }else{
	   telphone="";
	 }
   memset(caCmdCon,0,sizeof(caCmdCon));
   sprintf(caCmdCon,"echo 'telphone=%s' >> %s",telphone,pFile);
   system(caCmdCon);
   
	 //关键操作报警
	 if(ltMsgGetVar_s(ltMsgPk,"newadminalert")){
	 	 newadminalert=ltMsgGetVar_s(ltMsgPk,"newadminalert");
	 }else{
	   newadminalert="no";	
	 }
   memset(caCmdCon,0,sizeof(caCmdCon));
   sprintf(caCmdCon,"echo 'newadminalert=%s' >> %s",newadminalert,pFile);
   system(caCmdCon);
   
	 if(ltMsgGetVar_s(ltMsgPk,"newrulealert")){
	 	 newrulealert=ltMsgGetVar_s(ltMsgPk,"newrulealert");
	 }else{
	   newrulealert="no";	
	 }
   memset(caCmdCon,0,sizeof(caCmdCon));
   sprintf(caCmdCon,"echo 'newrulealert=%s' >> %s",newrulealert,pFile);
   system(caCmdCon);
   
	 if(ltMsgGetVar_s(ltMsgPk,"delrulealert")){
	 	 delrulealert=ltMsgGetVar_s(ltMsgPk,"delrulealert");
	 }else{
	   delrulealert="no";	
	 }
   memset(caCmdCon,0,sizeof(caCmdCon));
   sprintf(caCmdCon,"echo 'delrulealert=%s' >> %s",delrulealert,pFile);
   system(caCmdCon);
	 //网络异常报警
	 if(ltMsgGetVar_s(ltMsgPk,"outflowalert")){
	 	 outflowalert=ltMsgGetVar_s(ltMsgPk,"outflowalert");
	 }else{
	   outflowalert="";
	 }
   memset(caCmdCon,0,sizeof(caCmdCon));
   sprintf(caCmdCon,"echo 'outflowalert=%s' >> %s",outflowalert,pFile);
   system(caCmdCon);

	 
	 if(ltMsgGetVar_s(ltMsgPk,"p2pflowalert")){
	 	 p2pflowalert=ltMsgGetVar_s(ltMsgPk,"p2pflowalert");
	 }else{
	   p2pflowalert="";
	 }
   memset(caCmdCon,0,sizeof(caCmdCon));
   sprintf(caCmdCon,"echo 'p2pflowalert=%s' >> %s",p2pflowalert,pFile);
   system(caCmdCon);

	 ltMsgPk->msgpktype=1;
	 lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=uft-8\n",
	 "lthtml",LT_TYPE_STRING,"<html><body bgcolor=\"#cccccc\" >系统安全设置成功!</body></html>");
	 ltMsgFree(ltMsgPk);
   
   return 0;
}
Ejemplo n.º 9
0
int msaReportUserLineAjaxSubmit(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead)
{	
		printf("msaReportUserLineAjaxSubmit.................................\n");
    ltDbCursor  *tempCursor;
    LT_DBROW    tempRow;
    ltDbHeadPtr dbPtr;
    ltTablePtr  tablePtr;
    
    char sqlBuf[1024];    
    char caSdate[32],caEdate[32],caSdate1[32],caSdate2[32];
		char *reportname=NULL;
		char *email=NULL;
		char *step=NULL;
		long gid=-1,uid=-1;
		char *lt_page_content=NULL;
		char caTempDir[256]; 
		char responseDir[256]; 
    char caLabel[256];
    char strdayflow[32];
    unsigned long long lMaxBytes=1;
    unsigned long tmpDir=0;
    unsigned long fileName=0;
		
    long lTime,lTime1,lTime2; 
    int  iFd=-1;
    int  srvindex;
    
    
     //连接数据库
  	char *dbUser;
	  char *dbPass;
	  char *dbName;
	  dbName=_ltPubInfo->_dbname;
		dbUser=_ltPubInfo->_dbuser;
		dbPass=_ltPubInfo->_dbpass;
		G_DbCon=ltDbConnect(dbUser,dbPass,dbName);
		if(G_DbCon!=NULL){
			printf("db connect ok\n");
		}else{
			fprintf(stderr,"db connect error\n");
		}
    
    

	  /***************************ajax参数********************/
		if(ltMsgGetVar_s(ltMsgPk,"sdate")){
	  	sprintf(caSdate,"%s",ltMsgGetVar_s(ltMsgPk,"sdate"));
	  }else{
	  	sprintf(caSdate,"%s","");
	  }
printf("caSdate:%s\n",caSdate);
	  
	  if(ltMsgGetVar_s(ltMsgPk,"edate")){
	  	 sprintf(caEdate,"%s",ltMsgGetVar_s(ltMsgPk,"edate"));
	  }else{
	  	 sprintf(caEdate,"%s","");
	  }
printf("caEdate:%s\n",caEdate);
		
		if(ltMsgGetVar_s(ltMsgPk,"reportname")){	
	  	reportname=ltMsgGetVar_s(ltMsgPk,"reportname");
	  }
printf("reportname:%s\n",reportname);
	  
	  if(ltMsgGetVar_s(ltMsgPk,"email")){
	  	email=ltMsgGetVar_s(ltMsgPk,"email");
	  }
printf("email:%s\n",email);
	  
	  if(ltMsgGetVar_s(ltMsgPk,"step")){
	  	step=ltMsgGetVar_s(ltMsgPk,"step");
	  }
printf("step:%s\n",step);
    
    if(ltMsgGetVar_s(ltMsgPk,"gid")){
	  	gid=atol(ltMsgGetVar_s(ltMsgPk,"gid"));
	  }
printf("gid:%ld\n",gid);

	  if(ltMsgGetVar_s(ltMsgPk,"uid")&&atol(ltMsgGetVar_s(ltMsgPk,"uid"))!=0){
	  	uid=atol(ltMsgGetVar_s(ltMsgPk,"uid"));
	  }else{
	  	uid=-1;
	  }
printf("uid:%ld\n",uid);
    
	  if(ltMsgGetVar_s(ltMsgPk,"filedir")){	  
	  	fileName=atoll(ltMsgGetVar_s(ltMsgPk,"filedir"));
	  }else{
	  	fileName=0;
	  }
printf("fileName:%ld\n",fileName);    
    
    /****************目录生成************************/
    if(fileName==0){
		    tmpDir=ltStrGetId();
		    sprintf(caTempDir,"%s/%lu/",userreportdatacenterdir,tmpDir);
		    sprintf(responseDir,"%lu",tmpDir);	
		    if(ltFileIsExist(caTempDir)!=1){
		       if(mkdir(caTempDir,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)!=0) {
				      ltMsgPk->msgpktype=1;
							lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\n","lthtml",LT_TYPE_STRING,"0");		
							ltMsgFree(ltMsgPk);
			        return 0;
       		 }
    		} 
     }else{//从第二步开始传进第一步生成的目录
    	  sprintf(caTempDir,"%s/%lu/",userreportdatacenterdir,fileName);   
    	  sprintf(responseDir,"%lu",fileName);
     } 


    /***********************日期处理*****************/
    lTime = time(0);
    if(!ltStrIsSpaces(caSdate)){
        lTime1 = nasCvtLongTime(caSdate,"00:00:00");
    }else{
        lTime1 = 0;
    } 
    if(!ltStrIsSpaces(caEdate)) {
        lTime2 = nasCvtLongTime(caEdate,"23:59:59");
    }else{
        lTime2 = 0;
    } 
    
    if(lTime1 == 0) {
         lTime1 = lTime;       
    }
	  if(lTime2 == 0) {
         lTime2 = lTime;
    }
	  if(lTime1 > lTime) {
         lTime1 = lTime;
    }
    if(lTime2>lTime){
		 		 lTime2=lTime;
	  }
	  
	  
	  /******************************拷贝模板报告文件*************************/
	  char sDate[64],sTime[64];
	  char caFile1[256];   
    char caCmd[256];
    int  fdwrite=0;
    nasTimeGetDate(caSdate1,lTime);
    nasCvtStime(time(0),sDate,sTime); 
    sprintf(caFile1,"%sinfo.ini",caTempDir);     
    fdwrite = open(caFile1, O_APPEND | O_WRONLY | O_CREAT, 0644);
		if(fdwrite == (-1)) {
			 ltMsgPk->msgpktype=1;
			 lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\n","lthtml",LT_TYPE_STRING,"0");		
			 ltMsgFree(ltMsgPk);
			 return 0;
		}
		
		sprintf(caCmd,"date=%s_%s\n",sDate,sTime);
	  write(fdwrite,caCmd,strlen(caCmd));
	  sprintf(caCmd,"reportname=%s\n",reportname);
	  write(fdwrite,caCmd,strlen(caCmd));
	  close(fdwrite);
    sprintf(caLabel,"/bin/echo '1' > %sproccess.ini",caTempDir);
    system(caLabel);
	  sprintf(caLabel,"/bin/cp %s/right-top-d.jpg  %s",userlineplt,caTempDir);
    system(caLabel);
    sprintf(caLabel,"/bin/cp %s/right-top.jpg  %s",userlineplt,caTempDir);
    system(caLabel);
	  sprintf(caLabel,"/bin/cp %s/banner.jpg  %s",userlineplt,caTempDir);
    system(caLabel);
	  sprintf(caLabel,"/bin/cp %s/up-1.jpg  %s",userlineplt,caTempDir);
    system(caLabel);
	  sprintf(caLabel,"/bin/cp %s/up-2.jpg  %s",userlineplt,caTempDir);
    system(caLabel);
  	sprintf(caLabel,"/bin/cp %s/up-3.jpg  %s",userlineplt,caTempDir);
    system(caLabel);
    
    ltMsgPk->msgpktype=1;
	  lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\n","lthtml",LT_TYPE_STRING,responseDir);		
    
    
    /*************************数据库操作***************************************/  
    nasTimeGetDate(caSdate1,lTime1);
    nasTimeGetDate(caSdate2,lTime2);
    if(atoi(step)==1){//根据时间段生成服务协议分析流量汇总报表
      sprintf(sqlBuf,"select service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 group by service order by service,abyte asc",caSdate1,caSdate2); 
printf("sqlBufno.1: %s\n",sqlBuf);
    }else if(atoi(step)==2){
    	  if(uid!=-1&&gid!=-1){
    	  	sprintf(sqlBuf,"select c.name,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 and c.id=%ld and b.userid=%ld group by c.name,service order by c.name",caSdate1,caSdate2,gid,uid); 
    	  }else if(uid==-1&&gid!=-1){
    	    sprintf(sqlBuf,"select c.name,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 and c.id=%ld group by c.name,service order by c.name",caSdate1,caSdate2,gid);    
    	  }else{
    	    sprintf(sqlBuf,"select c.name,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 group by c.name,service order by c.name",caSdate1,caSdate2);    
    	  }
printf("sqlBufno.2: %s\n",sqlBuf);
    }else if(atoi(step)==3){
    	  if(uid!=-1&&gid!=-1){
    	  	  sprintf(sqlBuf,"select c.name,b.dispname,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 and c.id=%ld and b.userid=%ld group by c.name,b.dispname,service order by c.name,b.dispname,abyte asc",caSdate1,caSdate2,gid,uid); 
    	  }else if(uid==-1&&gid!=-1){
	    	  	sprintf(sqlBuf,"select c.name,b.dispname,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 and c.id=%ld group by c.name,b.dispname,service order by c.name,b.dispname,abyte asc",caSdate1,caSdate2,gid);
	    	}else{
	    	  	sprintf(sqlBuf,"select c.name,b.dispname,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 group by c.name,b.dispname,service order by c.name,b.dispname,abyte asc",caSdate1,caSdate2);
	    	}
printf("sqlBufno.3: %s\n",sqlBuf);
    }else if(atoi(step)==4){
    	  if(uid!=-1){
    	  	  sprintf(sqlBuf,"select c.name,b.dispname,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte,onlinetime from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 and c.id=%ld and b.userid=%ld group by c.name,b.dispname,service,onlinetime order by c.name,b.dispname,onlinetime asc",caSdate1,caSdate2,gid,uid); 
    	  }else if(uid==-1&&gid!=-1){
    	  		sprintf(sqlBuf,"select c.name,b.dispname,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte,onlinetime from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 and c.id=%ld group by c.name,b.dispname,service,onlinetime order by c.name,b.dispname,onlinetime asc",caSdate1,caSdate2,gid);
    	  }else{
    	  		sprintf(sqlBuf,"select c.name,b.dispname,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte,onlinetime from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 group by c.name,b.dispname,service,onlinetime order by c.name,b.dispname,onlinetime asc",caSdate1,caSdate2);
    	  }
printf("sqlBufno.4: %s\n",sqlBuf);
    }else if(atoi(step)==5){
    	  if(uid!=-1){
    	  	  sprintf(sqlBuf,"select c.name,b.dispname,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte,onlinetime from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 and c.id=%ld and b.userid=%ld group by c.name,b.dispname,service,onlinetime order by abyte desc limit 30",caSdate1,caSdate2,gid,uid); 
    	  }else if(uid==-1&&gid!=-1){
    	 		  sprintf(sqlBuf,"select c.name,b.dispname,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte,onlinetime from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 and c.id=%ld group by c.name,b.dispname,service,onlinetime order by abyte,c.name desc limit 30",caSdate1,caSdate2,gid);
    		}else{
    	 		  sprintf(sqlBuf,"select c.name,b.dispname,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte,onlinetime from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 group by c.name,b.dispname,service,onlinetime order by abyte,c.name desc limit 30",caSdate1,caSdate2);
    		}
printf("sqlBufno.5: %s\n",sqlBuf);
    }else if(atoi(step)==6){
    	  if(uid!=-1){
    	  	  sprintf(sqlBuf,"select c.name,b.dispname,a.host,d.url,sum(ctime) as arequest from msauserhttpreport a,msauser b,msaGroup c,nasurls d where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and c.id=b.groupid0 and b.userid=a.userid and a.urlsort=d.urlsort and c.id=%ld and b.userid=%ld group by c.name,b.dispname,d.url,a.bytes,host order by c.name,arequest desc limit 30",caSdate1,caSdate2,gid,uid); 
    	  }else if(uid==-1&&gid!=-1){
    	      sprintf(sqlBuf,"select c.name,b.dispname,a.host,d.url,sum(ctime) as arequest from msauserhttpreport a,msauser b,msaGroup c,nasurls d where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and c.id=b.groupid0 and b.userid=a.userid and a.urlsort=d.urlsort and c.id=%ld group by c.name,b.dispname,d.url,a.bytes,host order by c.name,arequest desc limit 30",caSdate1,caSdate2,gid);
    	  }else{
    	      sprintf(sqlBuf,"select c.name,b.dispname,a.host,d.url,sum(ctime) as arequest from msauserhttpreport a,msauser b,msaGroup c,nasurls d where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and c.id=b.groupid0 and b.userid=a.userid and a.urlsort=d.urlsort group by c.name,b.dispname,d.url,a.bytes,host order by c.name,arequest desc limit 30",caSdate1,caSdate2);
    	      								
    	  }
printf("sqlBufno.6: %s\n",sqlBuf);
    }else if(atoi(step)==7){
    	  if(uid!=-1){
    	  	  sprintf(sqlBuf,"select sdate,c.name,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 and c.id=%ld and b.userid=%ld group by c.name,service,sdate order by sdate",caSdate1,caSdate2,gid,uid); 
    	  }else if(uid==-1&&gid!=-1){
    	 		  sprintf(sqlBuf,"select sdate,c.name,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 and c.id=%ld group by c.name,service,sdate order by sdate",caSdate1,caSdate2,gid);
    	 	}else{
    	 		  sprintf(sqlBuf,"select sdate,c.name,service,sum(ctime) as arequest,sum(ubytes+dbytes) as abyte from msasrvreport a,msauser b,msaGroup c where substring(sdate,3,8)>='%s' and substring(sdate,3,8)<='%s' and a.userid=b.userid and c.id=b.groupid0 group by c.name,service,sdate order by sdate",caSdate1,caSdate2);
    	 	}
printf("sqlBufno.7: %s\n",sqlBuf);
    }
    tempCursor = ltDbOpenCursor(G_DbCon,sqlBuf);
	  if(tempCursor == NULL){
		      sprintf(caLabel,"/bin/echo '%s' > %serrmsg.ini","数据库错误,无法生成报告",caTempDir); 
	    	  system(caLabel);
	    	  ltMsgFree(ltMsgPk); 
	        return 0;
	  }
	  
	  /************图片数据存储文件****************/
	  if(atoi(step)==1){
		   sprintf(caLabel,"%sdata.ini",caTempDir);
	      iFd = open(caLabel,O_WRONLY | O_CREAT | O_TRUNC);
		    if(iFd == (-1)){
						sprintf(caLabel,"/bin/echo '%s' > %serrmsg.ini","无法建立数据文件",caTempDir);
			    	system(caLabel);/*建立目录和正在处理标志*/
			      ltDbCloseCursor(tempCursor);
			      ltMsgFree(ltMsgPk);
			      return 0;
			}							
	  }
	  
	  /**********************将数据显示的HTML页面*********************************/
	  srvindex=1;
	  lMaxBytes=1;
    dbPtr=lt_dbinit();
    lt_db_htmlpage(dbPtr,"utf-8");
    tablePtr=lt_dbput_table(dbPtr,"list");
	  tempRow= ltDbFetchRow(tempCursor);
	  while(tempRow!=NULL){	      			
				/**********************模板化参数****************************************/    
					if(atoi(step)==1){
						 /***********流量单位转化*****************/
					  if(atoll(tempRow[2])>1024000){
					      sprintf(strdayflow,"%0.3fM",atoll(tempRow[2])/1024000.00);
					  }else{
					      sprintf(strdayflow,"%0.3fK",atoll(tempRow[2])/1024.00);
					  }
					  sprintf(caLabel,"%d,%lld\r\n",srvindex,atoll(tempRow[2]));
	          write(iFd, caLabel, strlen(caLabel));
					  
					  if(lMaxBytes<atoll(tempRow[2])){
		         		lMaxBytes=atoll(tempRow[2]);
		        }	
		        
						lt_dbput_recordvars(tablePtr,3,
							"srvname",LT_TYPE_STRING,_ltPubInfo->topSrvName[atol(tempRow[0])].srvname,  
			   			"srvljnum",LT_TYPE_STRING,tempRow[1],
			   			"srvljflow",LT_TYPE_STRING,strdayflow
		   		  ); 
					}else if(atoi(step)==2){
						/***********流量单位转化*****************/
					  if(atoll(tempRow[3])>1024000){
					      sprintf(strdayflow,"%0.3fM",atoll(tempRow[3])/1024000.00);
					  }else{
					      sprintf(strdayflow,"%0.3fK",atoll(tempRow[3])/1024.00);
					  }
						
						if(lMaxBytes<atoll(tempRow[3])){
		         		lMaxBytes=atoll(tempRow[3]);
		        }	
						
						lt_dbput_recordvars(tablePtr,4,
						  "srvgname",LT_TYPE_STRING,tempRow[0],
							"srvname",LT_TYPE_STRING,_ltPubInfo->topSrvName[atol(tempRow[1])].srvname,  
			   			"srvljnum",LT_TYPE_STRING,tempRow[2],
			   			"srvljflow",LT_TYPE_STRING,strdayflow
		   		  );
					}else if(atoi(step)==3){
						/***********流量单位转化*****************/
					  if(atoll(tempRow[4])>1024000){
					      sprintf(strdayflow,"%0.3fM",atoll(tempRow[4])/1024000.00);
					  }else{
					      sprintf(strdayflow,"%0.3fK",atoll(tempRow[4])/1024.00);
					  }
					  
						if(lMaxBytes<atoll(tempRow[4])){
		         		lMaxBytes=atoll(tempRow[4]);
		        }
		        
						lt_dbput_recordvars(tablePtr,5,
						  "srvgname",LT_TYPE_STRING,tempRow[0],
						  "srvuname",LT_TYPE_STRING,tempRow[1],
							"srvname",LT_TYPE_STRING,_ltPubInfo->topSrvName[atol(tempRow[2])].srvname,  
			   			"srvljnum",LT_TYPE_STRING,tempRow[3],
			   			"srvljflow",LT_TYPE_STRING,strdayflow
		   		  );
					}else if(atoi(step)==4){
						/***********流量单位转化*****************/
					  if(atoll(tempRow[4])>1024000){
					      sprintf(strdayflow,"%0.3fM",atoll(tempRow[4])/1024000.00);
					  }else{
					      sprintf(strdayflow,"%0.3fK",atoll(tempRow[4])/1024.00);
					  }
					  
						if(lMaxBytes<atoll(tempRow[4])){
		         		lMaxBytes=atoll(tempRow[4]);
		        }
		        
						lt_dbput_recordvars(tablePtr,6,
						  "srvgname",LT_TYPE_STRING,tempRow[0],
						  "srvuname",LT_TYPE_STRING,tempRow[1],
							"srvname",LT_TYPE_STRING,_ltPubInfo->topSrvName[atol(tempRow[2])].srvname,  
			   			"srvljnum",LT_TYPE_STRING,tempRow[3],
			   			"srvljflow",LT_TYPE_STRING,strdayflow,
			   			"srvonlinetime",LT_TYPE_STRING,tempRow[5]
		   		  );
					}else if(atoi(step)==5){
						/***********流量单位转化*****************/
					  if(atoll(tempRow[4])>1024000){
					      sprintf(strdayflow,"%0.3fM",atoll(tempRow[4])/1024000.00);
					  }else{
					      sprintf(strdayflow,"%0.3fK",atoll(tempRow[4])/1024.00);
					  }
					  
						if(lMaxBytes<atoll(tempRow[4])){
		         		lMaxBytes=atoll(tempRow[4]);
		        }
		        
						lt_dbput_recordvars(tablePtr,6,
						  "srvgname",LT_TYPE_STRING,tempRow[0],
						  "srvuname",LT_TYPE_STRING,tempRow[1],
							"srvname",LT_TYPE_STRING,_ltPubInfo->topSrvName[atol(tempRow[2])].srvname,  
			   			"srvljnum",LT_TYPE_STRING,tempRow[3],
			   			"srvljflow",LT_TYPE_STRING,strdayflow,
			   			"srvonlinetime",LT_TYPE_STRING,tempRow[5]
		   		  );
					}else if(atoi(step)==6){
						lt_dbput_recordvars(tablePtr,5,
						  "srvgname",LT_TYPE_STRING,tempRow[0],
						  "srvuname",LT_TYPE_STRING,tempRow[1],
							"srvnetname",LT_TYPE_STRING,tempRow[2],  
			   			"srvurlname",LT_TYPE_STRING,tempRow[3], 
			   			"srvljnum",LT_TYPE_STRING,tempRow[4]
		   		  );
		      }else if(atoi(step)==7){
						/***********流量单位转化*****************/
					  if(atoll(tempRow[4])>1024000){
					      sprintf(strdayflow,"%0.3fM",atoll(tempRow[4])/1024000.00);
					  }else{
					      sprintf(strdayflow,"%0.3fK",atoll(tempRow[4])/1024.00);
					  }
					  
						if(lMaxBytes<atoll(tempRow[4])){
		         		lMaxBytes=atoll(tempRow[4]);
		        }
		        
						lt_dbput_recordvars(tablePtr,5,
						  "srvsdate",LT_TYPE_STRING,tempRow[0],
						  "srvgname",LT_TYPE_STRING,tempRow[1],
							"srvname",LT_TYPE_STRING,_ltPubInfo->topSrvName[atol(tempRow[2])].srvname,  
			   			"srvljnum",LT_TYPE_STRING,tempRow[3],
			   			"srvljflow",LT_TYPE_STRING,strdayflow
		   		  );
		      }
	   			if(atoi(step)==1){
	          	srvindex++;
	        }
        tempRow=ltDbFetchRow(tempCursor);//移动光标
    }
    ltDbCloseCursor(tempCursor);

    if(atoi(step)==1){//画图
			  close(iFd);	 
			  sprintf(caLabel,"/app/msa/msa/htmlplt/Scripts/onlinesrv-bar.pl  %sdata.ini %ssrvreport.gif %llu ",caTempDir,caTempDir,lMaxBytes);  //柱状 饼图:onlinesrv1.pl
			  system(caLabel);	
			  lt_dbput_rootvars(dbPtr,1,"piechart","srvreport.gif" );
	  } 
	  
	  lt_dbput_rootvars(dbPtr,3,"reportname",reportname,"bdate",caSdate1,"edate",caSdate2);
	  if(atoi(step)==1){
	    lt_page_content=ltPltFileParse("/app/msa/msa/htmlplt/reportplt/userlineplt/userflow.htm",dbPtr->doc,0);
	  }else if(atoi(step)==2){
			lt_page_content=ltPltFileParse("/app/msa/msa/htmlplt/reportplt/userlineplt/userflow2.htm",dbPtr->doc,0);
	  }else if(atoi(step)==3){
			lt_page_content=ltPltFileParse("/app/msa/msa/htmlplt/reportplt/userlineplt/userflow3.htm",dbPtr->doc,0);
	  }else if(atoi(step)==4){
			lt_page_content=ltPltFileParse("/app/msa/msa/htmlplt/reportplt/userlineplt/userflow4.htm",dbPtr->doc,0);
	  }else if(atoi(step)==5){
			lt_page_content=ltPltFileParse("/app/msa/msa/htmlplt/reportplt/userlineplt/userflow5.htm",dbPtr->doc,0);
	  }else if(atoi(step)==6){
			lt_page_content=ltPltFileParse("/app/msa/msa/htmlplt/reportplt/userlineplt/userflow6.htm",dbPtr->doc,0);
	  }else if(atoi(step)==7){
			lt_page_content=ltPltFileParse("/app/msa/msa/htmlplt/reportplt/userlineplt/userflow7.htm",dbPtr->doc,0);
	  }

	  if(lt_page_content==NULL){
		    sprintf(caLabel,"/bin/echo '%s' > %serrmsg.ini","无报告数据,无法生成报告",caTempDir);
	  		system(caLabel);/*建立目录和正在处理标志*/
	  		ltMsgFree(ltMsgPk);
	  		lt_dbfree(dbPtr);
     		return 0;
		}else{
			  lt_page_content=strstr(lt_page_content,"<!DOCTYPE");
			  if(atoi(step)==1){
			  	sprintf(caLabel,"%sindex.htm",caTempDir);
			  }else if(atoi(step)==2){
			  	sprintf(caLabel,"%spage2.htm",caTempDir);
			  }else if(atoi(step)==3){
			  	sprintf(caLabel,"%spage3.htm",caTempDir);
			  }else if(atoi(step)==4){
			  	sprintf(caLabel,"%spage4.htm",caTempDir);
			  }else if(atoi(step)==5){
			  	sprintf(caLabel,"%spage5.htm",caTempDir);
			  }else if(atoi(step)==6){
			  	sprintf(caLabel,"%spage6.htm",caTempDir);
			  }else{
			  	sprintf(caLabel,"%spage7.htm",caTempDir);
			  }			  
			  iFd = open(caLabel,O_WRONLY | O_NDELAY | O_TRUNC | O_CREAT,0644); 
		    if(iFd >0) {
		          write(iFd,lt_page_content,strlen(lt_page_content));
		    }
	    	close(iFd);
	  }
   	
    if(atoi(step)==7){
	    sprintf(caLabel,"/app/msa/msa/htmlplt/Scripts/html2mail  %s index.htm %sindex.mht report %s",caTempDir,caTempDir,email);
	    system(caLabel);
    }
    
    chdir(caTempDir);
	  system("rm -f report.tgz"); 
	  system("tar -cvzf report.tgz *");  
	  sprintf(caLabel,"/bin/rm  %sproccess.ini",caTempDir);
	  system(caLabel);    
	  sprintf(caLabel,"/bin/rm  %serrmsg.ini",caTempDir);
	  system(caLabel);   

	  ltMsgFree(ltMsgPk);
	  lt_dbfree(dbPtr);
	  
printf("caTempDir:::::::::%s\n",caTempDir);///datacenter/msa/report/weblinereport/71540000/
printf("responseDir:::::::::%s\n",responseDir);///datacenter/msa/report/weblinereport/71540000/
		//把web主线生成的报告备份到手动生成报告列表
		//system("cp -r -f /datacenter/msa/report/userlinereport/* /datacenter/msa/report/instantreport/");
    return 0;

}
Ejemplo n.º 10
0
int ltCgiDoUpload(ltCgiConfInfo *psCgiConf,char *curPath)
{
    ltCgiEntryU *psEntries;
    ltCgiEntry  *psCookies;
    char  *pcSetCookie,*p;
    int   totalVar,totalCookie,iServer;
    long  lFunCode;
    ltMsgHead *MsgHead,*getMsgHead;
    int i,iResult;
    int iSocket;
    int errint;
    

	 
	psEntries = ltCgiUpLoad(stdin,psCgiConf->upLoadPath,&totalVar,&errint);
	
	if(psEntries==NULL){
		if(errint==-100){
			printf(ltCgiMsgErr("<H1><b>上传的文件超过了系统的允许值</b></H1><br><br>"));
		        return 0;
		}else{
			printf(ltCgiMsgErr("<H1><b>系统错误,没有任何参数</b></H1><br><br>"));
		        return 0;
		}
	}
	
  

	pcSetCookie = (char *)getenv("HTTP_COOKIE");
	if(pcSetCookie != NULL)
	{
	    psCookies = ltCgiRetrieveCookie(pcSetCookie,&totalCookie);
	}
	else {
        totalCookie = 0;
	    psCookies = NULL;
	}
    
    
    
    MsgHead = ltMsgInit(psCgiConf->lMsgCode, 0, ltStrGetId(),1024);
    if (MsgHead == NULL ) {
        printf(ltCgiMsgErr("<H1><b>Create Msg package error!</b></H1><br><br>Memory overload!"));
        exit(0);
    }

 

    for(i=0;i < totalVar;i++)
    {

     if(strncmp(psEntries[i].name,"Fun",3) == 0)
       {    
           lFunCode = (int)ltMd5Code(psEntries[i].val,strlen(psEntries[i].val),"LT");
           MsgHead->lFunCode = lFunCode;
       }else if(psEntries[i].name[0] != 0) {
            if(psEntries[i].iType == 2) { /* 文件存放在结构中  */
                ltMsgAdd_v(&MsgHead,psEntries[i].name,psEntries[i].val,psEntries[i].iLen);
            }
            else { 
                ltMsgAdd_s(&MsgHead,psEntries[i].name,psEntries[i].val);
            }
       }
    }
    ltCgiFreeEntriesU(psEntries,totalVar);
    if(lFunCode == 0) {
       printf(ltCgiMsgErr("<H1><b>Function set error!</b></H1><br><br>"));
       free(MsgHead);
       return 0;
    }

    for (i=0;i<totalCookie;i++) {
       ltMsgAdd_s(&MsgHead,psCookies[i].name,psCookies[i].val);
    }

    ltCgiFreeEntries(psCookies,totalCookie);
    ltCgiSendEnvTo(&MsgHead);
 /*
 printf("Content-type: text/html\n\n");
	
    printf("xxxxx\n");
   
	 return 0;
*/
    //iSocket = ltCgiConnect(psCgiConf);
    iSocket = ltCgiConnect(psCgiConf);

    if(iSocket == -1) {
        printf(ltCgiMsgErr("<H1><b>系统暂时不让连接,可能在处理关键业务,30秒钟后重试!</b></H1><br><br>"));
        free(MsgHead);
        return 0;
    }
    else {

        iResult = lt_TcpMsgSend(iSocket,MsgHead);
				free(MsgHead);
        if(iResult == -1)
        {
            ltCgiMsgErr("Message Send Error!\n");
        }
        else {
        	  int readtime;
        	  readtime=0;
        	
            getMsgHead = lt_TcpMsgRead(iSocket,&errint);
            while(getMsgHead == NULL && errint !=0)
            {

               getMsgHead = lt_TcpMsgRead(iSocket,&errint);
               readtime++;
               
               sleep(4);
               if(readtime>=4){
               	break;
               }
	    			}	
            if(getMsgHead == NULL && errint !=0)
            {
               ltCgiMsgErr("<H1><b>系统没有返回数据,可能没有数据或参数不对!</b></H1><br><br>");
	    			}	
            else {
	       if(getMsgHead->msgpktype==0){/*xml*/
	               /*if ( (p = ltMsgGetVar_s(getMsgHead,"ltdbcontent"))!=NULL)
	               {
			   char *lt_page_content;
			   char *lt_head;
	   		   char *lt_charset;
			   xmlDocPtr ltDocPtr;
			   
		 	   ltDocPtr=xmlParseMemory(p,strlen(p));
	                   lt_page_content=ltPltFileParse(curPath,ltDocPtr);
		           lt_head=lt_dbget_head(ltDocPtr);
			   lt_charset=lt_dbget_charset(ltDocPtr);
			   
	  		   printf("%s",lt_head);
			  
			   printf("%s",lt_page_content);
			   xmlFreeDoc(ltDocPtr);
			   free(lt_page_content);
	     
	               }*/
		}
		else if( getMsgHead->msgpktype==1){/*html*/
			//printf("Content-type: text/html\n\n");
			//ltMsgPrintMsg(getMsgHead);
     			//return 0;
			if( (p = ltMsgGetVar_s(getMsgHead,"lthead"))!=NULL){
				 printf("%s\n",p);
			}else{
				 printf("Content-type: text/html\n");
			}
			if( (p = ltMsgGetVar_s(getMsgHead,"lthtml"))!=NULL){
				int plen;
				char *pTemp;
				int l;
				int iRead;
				plen=strlen(p);
				pTemp = malloc(plen + 1);
    				strcpy(pTemp,p);
    				pTemp[plen] = 0;
				
				l = 0;
				    while(l < plen) {
       					iRead = printf("%s",pTemp + l);
       					if(iRead == 0) iRead = 1;
       					l = l + iRead;
    				}
    				printf("\n");
    				free(pTemp);
			}
		}
		else if(getMsgHead->msgpktype==2){
			   char caFileName[128];
	                   char buf[4096];
	                   int  lSize;
    			  
	                   p = ltMsgGetVar_s(getMsgHead,"filename");
	                   if(p) {
	                       strcpy(caFileName,p);
	                   }
	                   else {
	                       strcpy(caFileName,"unknown.dat");
	                   }
	                   printf("Content-disposition: attachment; filename=\"%s\"\n",caFileName);
	                   if( (p = ltMsgGetVar_s(getMsgHead,"contenttype"))!=NULL){
			   	printf("Content-type: %s\n",p);
			   }else{
				printf("Content-type: application/octet-stream\n");
			   }
	                   printf("Content-transfer-encoding:BINARY\n\n");

	                   lSize =lt_saferead(iSocket,buf,sizeof(buf));
	                   while(lSize > 0) {
	                       fwrite(buf,lSize,1,stdout);
	                       lSize = lt_saferead(iSocket,buf,sizeof(buf));
	                   }
		}
               free(getMsgHead);
            }
        }
       close(iSocket);
     }
	
        return 0;
}
Ejemplo n.º 11
0
int ltqosdownlink(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){

	ltDbHeadPtr dbPtr;
	ltTablePtr tablePtr;
	ltDbCursor *tempCursor;
	LT_DBROW tempRow;
	char 				sqlBuf[1024];
	char        BANDDOWNLINK[24];
	char        myRate[24];
	int         mybrate;
	char        tmpDef[64],tempstr[128];
	int         qosid;
	
	char *dbUser;
	char *dbPass;
	char *dbName;
	dbName=_ltPubInfo->_dbname;
	dbUser=_ltPubInfo->_dbuser;
	dbPass=_ltPubInfo->_dbpass;
	G_DbCon=ltDbConnect(dbUser,dbPass,dbName);
	if(G_DbCon==NULL){
			ltMsgPk->msgpktype=1;
			lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: application/json\n","lthtml",LT_TYPE_STRING,"db error!");
			ltMsgFree(ltMsgPk);			
			return 0;
	}

	if(_bcKernelHead->banddownlink<1 ||_bcKernelHead->banduplink<1 ){
		  char    BANDUPLINK[24];
			char    BANDDOWNLINK[24];
		  memset(BANDDOWNLINK,0,sizeof(BANDDOWNLINK));
		 	bcCnfGetValue_s("/etc/msa/msa/qos/settings","BANDDOWNLINK",BANDDOWNLINK);
	    memset(BANDUPLINK,0,sizeof(BANDUPLINK));
			bcCnfGetValue_s("/etc/msa/msa/qos/settings","BANDUPLINK",BANDUPLINK);
			if(strlen(BANDUPLINK)>0 && strlen(BANDDOWNLINK)>0 ){
				_bcKernelHead->banddownlink=atol(BANDDOWNLINK);
				_bcKernelHead->banduplink=atol(BANDUPLINK);
			}
		  if(_bcKernelHead->banddownlink<1 ||_bcKernelHead->banduplink<1 ){
					ltbandlink(confd,ltMsgPk,lt_MMHead);
					return 0;
		  }
	}
	qosid=0;
	if(ltMsgGetVar_s(ltMsgPk,"qosid")!=NULL){
		qosid=atol(ltMsgGetVar_s(ltMsgPk,"qosid"));
	}
	dbPtr=lt_dbinit();
	lt_db_htmlpage(dbPtr,"utf-8");

  if(qosid!=0){

		  sprintf(sqlBuf,"select sid,qosname,qosrated,qosrateu,qosmixu,prio,qosmixd from msaqos where sid=%d",qosid);

			tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
			if(tempCursor!=NULL){
				tempRow= ltDbFetchRow(tempCursor);
				if(tempRow!=NULL){
					lt_dbput_rootvars(dbPtr,1,"sid",tempRow[0]);
					lt_dbput_rootvars(dbPtr,1,"qosname",tempRow[1]);
				  lt_dbput_rootvars(dbPtr,1,"qosrated",tempRow[2]);
				  lt_dbput_rootvars(dbPtr,1,"qosrateu",tempRow[3]);

				  lt_dbput_rootvars(dbPtr,1,"qosmixd",tempRow[4]);
				  lt_dbput_rootvars(dbPtr,1,"qosmixu",tempRow[6]);
				  
					tempRow= ltDbFetchRow(tempCursor);
				}else{
				  lt_dbput_rootvars(dbPtr,1,"qosname","NewQos");
				  lt_dbput_rootvars(dbPtr,1,"qosrated","0");
				  lt_dbput_rootvars(dbPtr,1,"qosrateu","0");
				  lt_dbput_rootvars(dbPtr,1,"sid","0" );
				  lt_dbput_rootvars(dbPtr,1,"qosmixd","0");
	        lt_dbput_rootvars(dbPtr,1,"qosmixu","0");
			  }
				ltDbCloseCursor(tempCursor);
			}else{
				  lt_dbput_rootvars(dbPtr,1,"qosname","NewQos");
				  lt_dbput_rootvars(dbPtr,1,"qosrated","0");
				  lt_dbput_rootvars(dbPtr,1,"qosrateu","0");
				  lt_dbput_rootvars(dbPtr,1,"sid","0");
				  lt_dbput_rootvars(dbPtr,1,"qosmixd","0");
	        lt_dbput_rootvars(dbPtr,1,"qosmixu","0");
		 }
  }else{
	  lt_dbput_rootvars(dbPtr,1,"qosname","NewQos");
	  lt_dbput_rootvars(dbPtr,1,"qosrated","0");
	  lt_dbput_rootvars(dbPtr,1,"qosrateu","0");
	  lt_dbput_rootvars(dbPtr,1,"sid","0");
	  lt_dbput_rootvars(dbPtr,1,"qosmixd","0");
	  lt_dbput_rootvars(dbPtr,1,"qosmixu","0");
	}

  sprintf(BANDDOWNLINK,"%lu",_bcKernelHead->banddownlink);
  lt_dbput_rootvars(dbPtr,1,"DOWNLINK",BANDDOWNLINK);

  sprintf(BANDDOWNLINK,"%lu",_bcKernelHead->banduplink);
  lt_dbput_rootvars(dbPtr,1,"UPLINK",BANDDOWNLINK);


  tablePtr=lt_dbput_table(dbPtr,"dqoslist");
  sprintf(sqlBuf,"select sid,qosname from msaqos where sid>0 ");
	tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
	if(tempCursor!=NULL){
		tempRow= ltDbFetchRow(tempCursor);
		while(tempRow!=NULL){
			 sprintf(tmpDef,"%s",tempRow[1]);
			lt_dbput_recordvars(tablePtr,2,
				"dsid",LT_TYPE_STRING,tempRow[0],
				"dqosname",LT_TYPE_STRING,tmpDef);
			tempRow= ltDbFetchRow(tempCursor);
		}
		ltDbCloseCursor(tempCursor);
	}


  mybrate=0;
  tablePtr=lt_dbput_table(dbPtr,"bqoslist");
  sprintf(sqlBuf,"select sid,qosname,qosmixd,qosrated from msaqos where sid>0 and qosmixd>0 ");
	tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
	if(tempCursor!=NULL){
		tempRow= ltDbFetchRow(tempCursor);
		while(tempRow!=NULL){

			mybrate=mybrate+atol(tempRow[2]);

			sprintf(myRate,"%d",(int)( (atol(tempRow[2])*100)/_bcKernelHead->banddownlink));
			
			memset(tempstr,0,sizeof(tempstr));
      strgb2utf8("保证通道",tempstr,strlen("保证通道"));
      printf("%s \n",tempstr);
			lt_dbput_recordvars(tablePtr,5,
				"bqosname",LT_TYPE_STRING,tempRow[1],
				"bqosrated",LT_TYPE_STRING,tempRow[2],
				"brate",LT_TYPE_STRING,myRate,
				"bqosrateu",LT_TYPE_STRING,tempRow[3],
				"btype",LT_TYPE_STRING,tempstr);
			tempRow= ltDbFetchRow(tempCursor);
		}
		ltDbCloseCursor(tempCursor);
	}
	if( _bcKernelHead->banddownlink>(mybrate+_bcKernelHead->banddowndef/1000)){
	   sprintf(myRate,"%lu", _bcKernelHead->banddownlink-mybrate );
	   lt_dbput_rootvars(dbPtr,1,"shareqos",myRate);
	   sprintf(myRate,"%d", (int)(((_bcKernelHead->banddownlink-mybrate)*100)/_bcKernelHead->banddownlink)  );
	   lt_dbput_rootvars(dbPtr,1,"sharerate",myRate);
  }else{
		 sprintf(myRate,"%d", _bcKernelHead->banddowndef/1000 );
		 lt_dbput_rootvars(dbPtr,1,"shareqos",myRate);
	   sprintf(myRate,"%d", (int)(((_bcKernelHead->banddowndef/1000)*100)/_bcKernelHead->banddownlink)  );
	   lt_dbput_rootvars(dbPtr,1,"sharerate",myRate);
	}





  tablePtr=lt_dbput_table(dbPtr,"sqoslist");
  sprintf(sqlBuf,"select sid,qosname,qosrated,qosrated from msaqos where sid>0 and qosmixd=0");
	tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
	if(tempCursor!=NULL){
		tempRow= ltDbFetchRow(tempCursor);
		while(tempRow!=NULL){


			sprintf(myRate,"%d",(int)((atol(tempRow[2])*100)/_bcKernelHead->banddownlink) );

			memset(tempstr,0,sizeof(tempstr));
      strgb2utf8("竞争通道",tempstr,strlen("竞争通道"));
			lt_dbput_recordvars(tablePtr,5,
				"sqosname",LT_TYPE_STRING,tempRow[1],
				"sqosrated",LT_TYPE_STRING,tempRow[2],
				"srate",LT_TYPE_STRING,myRate,
				"sqosrateu",LT_TYPE_STRING,tempRow[3],
				"stype",LT_TYPE_STRING,tempstr);
			tempRow= ltDbFetchRow(tempCursor);
		}
		ltDbCloseCursor(tempCursor);
	}


	/*shangchuang*/


  mybrate=0;
  tablePtr=lt_dbput_table(dbPtr,"upbqoslist");
  sprintf(sqlBuf,"select sid,qosname,qosmixu,qosrateu from msaqos where sid>0 and qosmixu>0");
	tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
	if(tempCursor!=NULL){
		tempRow= ltDbFetchRow(tempCursor);
		while(tempRow!=NULL){

			mybrate=mybrate+atol(tempRow[2]);

			sprintf(myRate,"%d",(int)( (atol(tempRow[2])*100)/_bcKernelHead->banduplink) );
			
			memset(tempstr,0,sizeof(tempstr));
      strgb2utf8("保证通道",tempstr,strlen("保证通道"));
			lt_dbput_recordvars(tablePtr,5,
				"upbqosname",LT_TYPE_STRING,tempRow[1],
				"upbqosrated",LT_TYPE_STRING,tempRow[2],
				"upbrate",LT_TYPE_STRING,myRate,
				"upbqosrateu",LT_TYPE_STRING,tempRow[3],
				"upbtype",LT_TYPE_STRING,tempstr);
			tempRow= ltDbFetchRow(tempCursor);
		}
		ltDbCloseCursor(tempCursor);
	}

	if( _bcKernelHead->banduplink >(mybrate+_bcKernelHead->bandupdef/1000)){
	   	sprintf(myRate,"%lu", _bcKernelHead->banduplink-mybrate );
	   	lt_dbput_rootvars(dbPtr,1,"upshareqos",myRate);
			sprintf(myRate,"%d", (int)(((_bcKernelHead->banduplink-mybrate)*100)/_bcKernelHead->banduplink)  );
			lt_dbput_rootvars(dbPtr,1,"upsharerate",myRate);
  }else{
		 sprintf(myRate,"%d", _bcKernelHead->bandupdef/1000 );
		 lt_dbput_rootvars(dbPtr,1,"upshareqos",myRate);
		 sprintf(myRate,"%d", (int)(((_bcKernelHead->bandupdef/1000)*100)/_bcKernelHead->banduplink)  );
		 lt_dbput_rootvars(dbPtr,1,"upsharerate",myRate);
	}






  tablePtr=lt_dbput_table(dbPtr,"upsqoslist");
  sprintf(sqlBuf,"select sid,qosname,qosrateu,qosrateu from msaqos where sid>0 and qosmixu=0 ");
	tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
	if(tempCursor!=NULL){
		tempRow= ltDbFetchRow(tempCursor);
		while(tempRow!=NULL){


			sprintf(myRate,"%d",(int)((atol(tempRow[2])*100)/_bcKernelHead->banduplink) );
			memset(tempstr,0,sizeof(tempstr));
      strgb2utf8("竞争通道",tempstr,strlen("竞争通道"));

			lt_dbput_recordvars(tablePtr,5,
				"upsqosname",LT_TYPE_STRING,tempRow[1],
				"upsqosrated",LT_TYPE_STRING,tempRow[2],
				"upsrate",LT_TYPE_STRING,myRate,
				"upsqosrateu",LT_TYPE_STRING,tempRow[3],
				"upstype",LT_TYPE_STRING,tempstr);
			tempRow= ltDbFetchRow(tempCursor);
		}
		ltDbCloseCursor(tempCursor);
	}

  lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msa/htmlplt/manager/bandconf.html",dbPtr->head,0);
	ltMsgFree(ltMsgPk);
	lt_dbfree(dbPtr);
	return 0;
}
Ejemplo n.º 12
0
int ltupdateqos(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){


	char 				sqlBuf[1024];
	char        *qosname;
	char        *qosrated;
	char        *prio;
	char        *qosmixd;
	char        *qosrateu;
	char        *qosmixu;
	long 				lCount;
	int         qosid;
	ltDbCursor *tempCursor;
	LT_DBROW tempRow;
	
	char *dbUser;
	char *dbPass;
	char *dbName;
	dbName=_ltPubInfo->_dbname;
	dbUser=_ltPubInfo->_dbuser;
	dbPass=_ltPubInfo->_dbpass;
	G_DbCon=ltDbConnect(dbUser,dbPass,dbName);
	if(G_DbCon==NULL){
			ltMsgPk->msgpktype=1;
			lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: application/json\n","lthtml",LT_TYPE_STRING,"db error!");
			ltMsgFree(ltMsgPk);			
			return 0;
	}

  qosid=atol(ltMsgGetVar_s(ltMsgPk,"qosid"));

  qosname=ltMsgGetVar_s(ltMsgPk,"qosname");
	if(qosname==NULL){
		qosname="";
	}

	qosrated=ltMsgGetVar_s(ltMsgPk,"qosrated");
	if(qosrated==NULL){
		qosrated="0";
	}

	prio=ltMsgGetVar_s(ltMsgPk,"prio");
	if(prio==NULL){
		prio="0";
	}

	qosmixd=ltMsgGetVar_s(ltMsgPk,"qosmixd");
	if(qosmixd==NULL){
		qosmixd="0";
	}

	qosrateu=ltMsgGetVar_s(ltMsgPk,"qosrateu");
	if(qosrateu==NULL){
		qosrateu="0";
	}

	qosmixu=ltMsgGetVar_s(ltMsgPk,"qosmixu");
	if(qosmixu==NULL){
		qosmixu="0";
	}
	if(ltStrIsDigital(qosrated)==0){
				ltMsgPk->msgpktype=1;
				lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=uft-8\n",
					"lthtml",LT_TYPE_STRING,"<html><body bgcolor=\"#cccccc\" >带宽数值不对! </body></html>");
				return 0;
	}
	if(ltStrIsDigital(qosrateu)==0){
				ltMsgPk->msgpktype=1;
				lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=uft-8\n",
					"lthtml",LT_TYPE_STRING,"<html><body bgcolor=\"#cccccc\" >带宽数值不对! </body></html>");
				return 0;
	}
	if(atol(qosrated)<2){
				ltMsgPk->msgpktype=1;
				lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=uft-8\n",
					"lthtml",LT_TYPE_STRING,"<html><body bgcolor=\"#cccccc\" >带宽数值太低,必须大于1K! </body></html>");
				return 0;
	}
	if(atol(qosrateu)<2){
				ltMsgPk->msgpktype=1;
				lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=uft-8\n",
					"lthtml",LT_TYPE_STRING,"<html><body bgcolor=\"#cccccc\" >带宽数值太低,必须大于1K! </body></html>");
				return 0;
	}

	if(qosid>0){


		sprintf(sqlBuf,"update msaqos set qosname='%s',qosrated=%s, qosrateu=%s, qosmixd=%s,qosmixu=%s,prio=%s where sid=%d",
			qosname,qosrated,qosrateu,qosmixd,qosmixu,prio,qosid);
		printf("%s  \n",sqlBuf);
	  ltDbExecSql(G_DbCon,sqlBuf);
		ltqosdownlink(confd,ltMsgPk,lt_MMHead);
	  return 0;
	}
	qosid=1;
	while(1){
			sprintf(sqlBuf,"select count(*) from msaqos where sid=%d ",qosid);
			lCount=0;
			tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
			if(tempCursor!=NULL){
							tempRow= ltDbFetchRow(tempCursor);
							if(tempRow!=NULL){
								lCount=atol(tempRow[0]);
							}
							ltDbCloseCursor(tempCursor);
			}
			if(lCount == 0) {
					break;
			}else{
		  		qosid++;
		  }
		  if(qosid>998){
		  	ltMsgPk->msgpktype=1;
				lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=uft-8\n",
					"lthtml",LT_TYPE_STRING,"<html><body bgcolor=\"#cccccc\" >通道超出系统限制! </body></html>");
				return 0;
		  }
	}


	sprintf(sqlBuf,"insert into msaqos values (%d,0,'%s',%s,%s,%s,%s,%s)",
			qosid,qosname,qosrated,qosrateu,qosmixd,qosmixu,prio);

	printf("sql;%s\n",sqlBuf);
	ltDbExecSql(G_DbCon,sqlBuf);

  ltqosdownlink(confd,ltMsgPk,lt_MMHead);
	return 0;
}
Ejemplo n.º 13
0
/*
*注册后查看所有用户
*/
int msasTestApp(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
    char *name;
	char *password;
	char *rePass;
    char myre[1024];
	char caStr[2048];
	char sqlBuf[2048];
    int  maxuid;

    ltDbCursor *tempCursor;
    LT_DBROW   tempRow;

    name=ltMsgGetVar_s(ltMsgPk,"txtName");
    if(!name){
         name="";
   }
	password=ltMsgGetVar_s(ltMsgPk,"txtPass");
    if(!password){
         password="";
   }
   rePass=ltMsgGetVar_s(ltMsgPk,"txtRePass");
    if(!rePass){
         rePass="";
   }
   if(strcmp(password,rePass)!=0){
       ltMsgPk->msgpktype=1;
       lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\r\n",
				"lthtml",LT_TYPE_STRING,"error!");   
      ltMsgFree(ltMsgPk);
      return 0;	
   }
   
   maxuid=1;
   sprintf(sqlBuf,"select max(uid)+1 from msasusertest" );
   tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);   
   if(tempCursor!=NULL){
          tempRow= ltDbFetchRow(tempCursor);
          if(tempRow!=NULL){
			  maxuid=atol(tempRow[0]);	
          }
     ltDbCloseCursor(tempCursor);
   }


   sprintf(sqlBuf,"insert into msasusertest values (%d,'%s','%s')",maxuid,name,password);
   ltDbExecSql(G_DbCon,sqlBuf); 
   
   memset(caStr,0,sizeof(caStr));
   sprintf(sqlBuf,"select * from msasusertest" );
   tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);   
   if(tempCursor!=NULL){ 
          tempRow= ltDbFetchRow(tempCursor);
		  //sprintf("%s%s%s",_ltPubInfo->pubMsgStr[1].conStr,_ltPubInfo->pubMsgStr[2].conStr,_ltPubInfo->pubMsgStr[3].conStr); 
          while(tempRow!=NULL){
			 sprintf(caStr,"%s%s %s %s\r\n<br>",caStr,tempRow[0],tempRow[1],tempRow[2]);
			 tempRow= ltDbFetchRow(tempCursor);
          }
        ltDbCloseCursor(tempCursor);
   }

	ltMsgPk->msgpktype=1;
    lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\r\n",
				"lthtml",LT_TYPE_STRING,caStr);   
    ltMsgFree(ltMsgPk);
    return 0;
}
Ejemplo n.º 14
0
int msasAdminLogon(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
	
	LT_DBROW tempRow;
	char sqlBuf[1024];
	ltDbHeadPtr dbPtr;
  char *strUserName;
	char *strPassword;
  char newPass[50];
	ltDbCursor *tempCursor;
	int logFlag;
	char sRight[64];

	int  i;
	
	char sIp[24];


	char strsid[12];
	char tmpsid[12];

	
	
  char langsel[12];
	char stylesel[12];
	char strusertype[12];
	
	
	memset(langsel,0,sizeof(langsel));
	memset(stylesel,0,sizeof(stylesel));
	memset(strusertype,0,sizeof(strusertype));
	
	sprintf(langsel,"%s","0");
	sprintf(stylesel,"%s","0");
	
	memset(sIp,0,sizeof(sIp));
	memset(strsid,0,sizeof(strsid));
	memset(tmpsid,0,sizeof(tmpsid));
	

	
	ltMsgGetSomeNVar(ltMsgPk,2,"sid",LT_TYPE_STRING, 19, strsid,
														"strsid",LT_TYPE_STRING, 19, tmpsid );
														
	sprintf(strsid,"%s",ltMsgGetVar_s(ltMsgPk,"sid"));
	
  if( strlen(langsel)<1 ){
  	sprintf(langsel,"%s","0");
  }
  if( strlen(stylesel)<1 ){
  	sprintf(stylesel,"%s","0");
  }
  
	logFlag=0;
	memset(newPass,0,sizeof(newPass));
	snprintf(sIp,19,ltMsgGetVar_s(ltMsgPk,"clientip"));
	strUserName=ltMsgGetVar_s(ltMsgPk,"username");
	strPassword=ltMsgGetVar_s(ltMsgPk,"password");
	
//printf("strsIndex:%s  sip:%s strUserName:%s stylesel:%s strsid:%s\n",strsIndex,sIp,strUserName,stylesel,strsid);

	ltMd5Encrypto(strPassword, strlen(strPassword),newPass);
	
	dbPtr=lt_dbinit();
	
//
//printf("strsid:%s ,tmpsid:%s\n",strsid,tmpsid);
//

  for(i=0;i<MAX_ADMIN_SESSION;i++){
  	if(_ltPubInfo->admSession[i].lSip==ntohl(inet_addr(sIp)) ){
          _ltPubInfo->admSession[i].lSip=0;
  			  _ltPubInfo->admSession[i].lasttime=0;
  				_ltPubInfo->admSession[i].trytimes=0;
  		    _ltPubInfo->admSession[i].lSid=0;
  		    sprintf(_ltPubInfo->admSession[i].lright,"%s","0000000000000000000000000000000000000000000");		   
  		   sprintf(strUserName,"%s",_ltPubInfo->admSession[i].caname );
  		
  	}
  }
	
  
	if( strcmp(strsid,tmpsid) ){
		ltMsgPk->msgpktype=1;
	  //ltWebMsgErr(strGmsg[atol(langsel)][atol(stylesel)][4], confd,ltMsgPk);
	  ltWebMsgErr(_ltPubInfo->pubMsgStr[0].conStr, confd,ltMsgPk);
	  
	  ltMsgFree(ltMsgPk);
		return 0;
	}
			

	i=0;
	sprintf(sqlBuf,"select name,lright,bindip from msasadmuser where name='%s' and password='******'",strUserName,newPass);		
	tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
	if(tempCursor!=NULL){
			tempRow= ltDbFetchRow(tempCursor);
			if(tempRow!=NULL){
					for(i=0;i<MAX_ADMIN_SESSION;i++){
						  	if(_ltPubInfo->admSession[i].lSip==0 || (time(0) -_ltPubInfo->admSession[i].lasttime ) > 7200   ){
						  		
						          _ltPubInfo->admSession[i].lSip=ntohl(inet_addr(sIp));
						          _ltPubInfo->admSession[i].lasttime=time(0);
											_ltPubInfo->admSession[i].trytimes=0;
											if(tempRow[2][0]){
												if(strcmp(tempRow[2],sIp)){
													logFlag=2;
												  break;
												}
											}
											sprintf(_ltPubInfo->admSession[i].caname,"%s",strUserName);
											sprintf(_ltPubInfo->admSession[i].lright,"%s",tempRow[1]);
											sprintf(sRight,"%s",tempRow[1]);
											logFlag=1;
					  		      break;
						  	}
					}
		}
		ltDbCloseCursor(tempCursor);
	}
	
  
	if(logFlag==1){
		/*
		unsigned long onlinetime;
		unsigned int sessionId; 
		char   sid[30];
		*/
		char   sid[30];
		lt_db_htmlpage(dbPtr,"utf-8");
		lt_db_setcookie(dbPtr,"manageruser", strUserName);
		//printf("set sRight:%s\n",sRight);
		//lt_db_setcookie(dbPtr,"sright", sRight);
		sprintf(sid,"%d",i);
		lt_db_setcookie(dbPtr,"langsel", langsel);
    lt_db_setcookie(dbPtr,"msassessionid", sid);
				  
		lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msas/htmlplt/main/main.htm",dbPtr->head,0);
		sprintf(sqlBuf,"update msasadmuser set lasttime=%ld where name='%s' ",time(0),strUserName); 
		ltDbExecSql(G_DbCon,sqlBuf); 
		  
			
			{
				int lTime;
				char  caDate[64];
				lTime = time(0);
	    	strcpy(caDate,ltTimeFormat("%Y-%m-%d %H:%M:%S",lTime));
				sprintf(sqlBuf,"insert into msasadmlog values('%s','%s','user login success! <from %s>','1')",strUserName,caDate,sIp); 
		    ltDbExecSql(G_DbCon,sqlBuf); 
		  }

		
	}else if(logFlag==2){
		 ltMsgPk->msgpktype=1;
 		 ltWebMsgErr(_ltPubInfo->pubMsgStr[1].conStr, confd,ltMsgPk);
		 return 0;
	}else{
	  
	  	{
				int lTime;
				char  caDate[64];
				lTime = time(0);
	    	strcpy(caDate,ltTimeFormat("%Y-%m-%d %H:%M:%S",lTime));
				sprintf(sqlBuf,"insert into msasadmlog values('%s','%s','user login failed! <from %s>','1')",strUserName,caDate,sIp); 
		    ltDbExecSql(G_DbCon,sqlBuf); 
		  }
	
		lt_db_htmlpage(dbPtr,"utf-8");
    
    ltWebMsgErr(_ltPubInfo->pubMsgStr[2].conStr, confd,ltMsgPk);
		
	  ltMsgFree(ltMsgPk);
		return 0;
		
	}
	
	ltMsgFree(ltMsgPk);
	lt_dbfree(dbPtr);
	return 0;

}
Ejemplo n.º 15
0
int showView(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead)
{
    
    char *caMatching_id;
    char *cagnmkey;
    char *casname;
    char *caRule_id;
    char *caRule_name;
    char *caMatching_time;
    char *caNet_ending_ip;
    char *caNet_ending_code;
    char *caNet_ending_mac;
    char *caDestination_ip;
    char *caService_type;
    char *caKeyWord1;
    char *caKeyWord2;
    char *caKeyWord3;
    char *caCustomer_name;
    char *caCertificate_type;
    char *caCertificate_code;
    char *caRule_type;
    char *cacontenturl;
    char *caupdateflag;



    //char myre[1024];
	char caStr[2048];
	char sqlBuf[2048];
    int  maxuid;

    ltDbCursor *tempCursor;
    LT_DBROW   tempRow;

	 caMatching_id=ltMsgGetVar_s(ltMsgPk,"txt_Matching_id");
    if(!caMatching_id){
         caMatching_id="";
   }
    cagnmkey=ltMsgGetVar_s(ltMsgPk,"txt_gnmkey");
    if(!cagnmkey){
         cagnmkey="";
   }
    casname=ltMsgGetVar_s(ltMsgPk,"txt_name");
    if(!casname){
         casname="";
   }
    caRule_id=ltMsgGetVar_s(ltMsgPk,"txt_Rule_id");
    if(!caRule_id){
         caRule_id="";
   }
    caRule_name=ltMsgGetVar_s(ltMsgPk,"txt_Rule_name");
    if(!caRule_name){
         caRule_name="";
   }
    caMatching_time=ltMsgGetVar_s(ltMsgPk,"txt_Matching_time");
    if(!caMatching_time){
         caMatching_time="";
   }
    caNet_ending_ip=ltMsgGetVar_s(ltMsgPk,"txt_Net_ending_ip");
    if(!caNet_ending_ip){
         caNet_ending_ip="";
   }
    caNet_ending_code=ltMsgGetVar_s(ltMsgPk,"txt_Net_ending_code");
    if(!caNet_ending_code){
         caNet_ending_code="";
   }
    caNet_ending_mac=ltMsgGetVar_s(ltMsgPk,"txt_Net_ending_mac");
    if(!caNet_ending_mac){
         caNet_ending_mac="";
   }
    caDestination_ip=ltMsgGetVar_s(ltMsgPk,"txt_Destination_ip");
    if(!caDestination_ip){
         caDestination_ip="";
   }
    caService_type=ltMsgGetVar_s(ltMsgPk,"txt_Service_type");
    if(!caService_type){
         caService_type="";
   }
    caKeyWord1=ltMsgGetVar_s(ltMsgPk,"txt_KeyWord1");
    if(!caKeyWord1){
         caKeyWord1="";
   }
    caKeyWord2=ltMsgGetVar_s(ltMsgPk,"txt_KeyWord2");
    if(!caKeyWord2){
         caKeyWord2="";
   }
    caKeyWord3=ltMsgGetVar_s(ltMsgPk,"txt_KeyWord3");
    if(!caKeyWord3){
         caKeyWord3="";
   }
    caCustomer_name=ltMsgGetVar_s(ltMsgPk,"txt_Customer_name");
    if(!caCustomer_name){
         caCustomer_name="";
   }
    caCertificate_type=ltMsgGetVar_s(ltMsgPk,"txt_Certificate_type");
    if(!caCertificate_type){
         caCertificate_type="";
   }
    caCertificate_code=ltMsgGetVar_s(ltMsgPk,"txtName");
    if(!caCertificate_code){
         caCertificate_code="";
   }
    caRule_type=ltMsgGetVar_s(ltMsgPk,"txt_Certificate_code");
    if(!caRule_type){
         caRule_type="";
   }
    cacontenturl=ltMsgGetVar_s(ltMsgPk,"txt_contenturl");
    if(!cacontenturl){
         cacontenturl="";
   }
    caupdateflag=ltMsgGetVar_s(ltMsgPk,"txt_updateflag");
    if(!caupdateflag){
         caupdateflag="";
   }
   
   maxuid=1;
   sprintf(sqlBuf,"select max(caMatching_id)+1 from AlertList" );
   tempCursor=ltDbOpenCursorS(G_DbCon,sqlBuf);   
   if(tempCursor!=NULL){
          tempRow= ltDbFetchRow(tempCursor);
          if(tempRow!=NULL){
			  maxuid=atol(tempRow[0]);	
          }
     ltDbCloseCursor(tempCursor);
   }
   
   memset(caStr,0,sizeof(caStr));
   sprintf(sqlBuf,"select * from AlertList" );
   tempCursor=ltDbOpenCursorS(G_DbCon,sqlBuf);   
   if(tempCursor!=NULL){ 
          tempRow= ltDbFetchRow(tempCursor);
          while(tempRow!=NULL){
			 sprintf(caStr,"%s%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\r\n<br>",caStr,tempRow[0],tempRow[1],tempRow[2],tempRow[3],tempRow[4],tempRow[5],tempRow[6],tempRow[7],tempRow[8],tempRow[9],tempRow[10],tempRow[11],tempRow[12],tempRow[13],tempRow[14],tempRow[15],tempRow[16],tempRow[17],tempRow[18],tempRow[19]);
			 tempRow= ltDbFetchRow(tempCursor);
          }
        ltDbCloseCursor(tempCursor);
   }

	ltMsgPk->msgpktype=1;
    lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=gb2312\r\n",
				"lthtml",LT_TYPE_STRING,caStr);   
    ltMsgFree(ltMsgPk);
    return 0;
}
Ejemplo n.º 16
0
/*加载服务特征修改页面*/
int ltupdateurlType(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
   char *my_id;
	 char pFile[512];
   stralloc strTemp;
   strTemp.s=0;
	 char strFile[256];
	 
   ltDbHeadPtr dbPtr;
   dbPtr=lt_dbinit();
   
   my_id=ltMsgGetVar_s(ltMsgPk,"my_id");
   dbPtr=lt_dbinit();
   lt_db_htmlpage(dbPtr,"utf-8");
   if(my_id!=NULL){
   	   sprintf(pFile,"/etc/msa/msa/srvlist/srvdefine/%s",my_id);
   		 
	     int   match;
			 static char inbuf[4096];
			 int   fd;
			 fd=open(pFile,O_RDONLY | O_NDELAY);
		   match=read(fd,inbuf,sizeof(inbuf));
			 int tt=access(pFile,0);//配置文件是否存在  不存在的话在页面上打印空
			 if(tt!=-1){
				 while(match){
				 	stralloc_catb(&strTemp,inbuf,match);
				 	match=read(fd,inbuf,sizeof(inbuf));
				 }
			   stralloc_0(&strTemp); 
	     }else{
	     	lt_dbput_rootvars(dbPtr,1,"srvid",my_id);
		    ltMsgPk->msgpktype=1;
		    lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msa/htmlplt/manager/updateSrvType.htm",dbPtr->head,0);
		    ltMsgFree(ltMsgPk);
		    ltDbClose(G_DbCon); 
		    return 0;
	     }
			 sprintf(strFile,"%s",strTemp.s);
			 char str[256];
			 char str1[256];		 
			 memset(str,0,sizeof(str));
			 memset(str1,0,sizeof(str1));
			 str[0]=strFile[0];
			 sprintf(str1,"matchAgree%ssel",str);
			 lt_dbput_rootvars(dbPtr,1,str1,"selected");//匹配协议

			 
			 memset(str,0,sizeof(str));
			 memset(str1,0,sizeof(str1));
			 str[0]=strFile[1];
			 sprintf(str1,"matchdirect%ssel",str);
			 lt_dbput_rootvars(dbPtr,1,str1,"selected");//匹配方向

			 
			 memset(str,0,sizeof(str));
			 memset(str1,0,sizeof(str1));
			 str[0]=strFile[2];
			 str[1]=strFile[3];
			 str[2]=strFile[4];
			 str[3]=strFile[5];
			 str[4]=strFile[6];
			 lt_dbput_rootvars(dbPtr,1,"matchportL",str);//端口L

			 
			 memset(str,0,sizeof(str));
			 memset(str1,0,sizeof(str1));
			 str[0]=strFile[7];
			 str[1]=strFile[8];
			 str[2]=strFile[9];
			 str[3]=strFile[10];
			 str[4]=strFile[11];
			 lt_dbput_rootvars(dbPtr,1,"matchportT",str);//端口T

			 
			 memset(str,0,sizeof(str));
			 memset(str1,0,sizeof(str1));
			 str[0]=strFile[12];
			 sprintf(str1,"matchload%ssel",str);
			 lt_dbput_rootvars(dbPtr,1,str1,"selected");//匹配方式

			 
			 memset(str,0,sizeof(str));
			 memset(str1,0,sizeof(str1));
			 str[0]=strFile[13];
			 str[1]=strFile[14];
			 str[2]=strFile[15];
			 str[3]=strFile[16];
			 lt_dbput_rootvars(dbPtr,1,"srvdescmatch1",str);//起始字节

			 
			 memset(str,0,sizeof(str));
			 memset(str1,0,sizeof(str1));
			 str[0]=strFile[17];
			 str[1]=strFile[18];
			 lt_dbput_rootvars(dbPtr,1,"srvdescmatch2",str);//字节总数

			 int strString=2*atoi(str);		 
			 memset(str,0,sizeof(str));
			 memset(str1,0,sizeof(str1));
		   int iii;int jjj=0;
		 	 for(iii=19;iii<=strString+18;iii++){
				 str[jjj]=strFile[iii];
				 jjj++;
			 }
printf("str:::%s\n",str);
			 lt_dbput_rootvars(dbPtr,1,"srvdescmatch3",str);//字节总数
			 
	     lt_dbput_rootvars(dbPtr,1,"srvid",my_id);
   }
   ltMsgPk->msgpktype=1;
   lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msa/htmlplt/manager/updateSrvType.htm",dbPtr->head,0);
   ltMsgFree(ltMsgPk);
   ltDbClose(G_DbCon); 
   return 0;
}
Ejemplo n.º 17
0
int lteditqos(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){

	char 				sqlBuf[1024];
	int         qosid;
	char        *edittype;
	ltDbCursor *tempCursor;
	LT_DBROW tempRow;
	
	char *dbUser;
	char *dbPass;
	char *dbName;
	dbName=_ltPubInfo->_dbname;
	dbUser=_ltPubInfo->_dbuser;
	dbPass=_ltPubInfo->_dbpass;
	G_DbCon=ltDbConnect(dbUser,dbPass,dbName);
	if(G_DbCon==NULL){
			ltMsgPk->msgpktype=1;
			lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: application/json\n","lthtml",LT_TYPE_STRING,"db error!");
			ltMsgFree(ltMsgPk);			
			return 0;
	}

	qosid=atol(ltMsgGetVar_s(ltMsgPk,"qosid"));
	edittype=ltMsgGetVar_s(ltMsgPk,"edittype");

	if(qosid==0){
		   ltMsgPk->msgpktype=1;
				lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=uft-8\n",
			"lthtml",LT_TYPE_STRING,"<html><body bgcolor=\"#cccccc\" >Error: this qos rule can't be chanage!</body></html>");
				ltMsgFree(ltMsgPk);

		    return 0;
	}

	if( strcmp(edittype,"setdef")==0){
	  ltqosdownlink(confd,ltMsgPk,lt_MMHead);
	  return 0;
	}else if( strcmp(edittype,"Del")==0){
		int lCount;
		lCount=0;
		sprintf(sqlBuf,"select count(*) from nassrvrule where qosid=%d ",qosid);
		tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
				if(tempCursor!=NULL){
						tempRow= ltDbFetchRow(tempCursor);
						if(tempRow!=NULL){
							lCount=atol(tempRow[0]);
						}
						ltDbCloseCursor(tempCursor);
				}
		if(lCount>0){
			 ltMsgPk->msgpktype=1;
				lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=uft-8\n",
			"lthtml",LT_TYPE_STRING,"<html><body bgcolor=\"#cccccc\" >警告: 该通道已经应用于规则,不能删除!</body></html>");
				ltMsgFree(ltMsgPk);
		    return 0;
		}
		
		lCount=0;
		sprintf(sqlBuf,"select count(*) from msauserpolicy where ratelimit=%d ",qosid);
		tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
				if(tempCursor!=NULL){
						tempRow= ltDbFetchRow(tempCursor);
						if(tempRow!=NULL){
							lCount=atol(tempRow[0]);
						}
						ltDbCloseCursor(tempCursor);
				}
		if(lCount>0){
			 ltMsgPk->msgpktype=1;
				lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=uft-8\n",
			"lthtml",LT_TYPE_STRING,"<html><body bgcolor=\"#cccccc\" >警告: 该通道已经应用于批量策略,不能删除!</body></html>");
				ltMsgFree(ltMsgPk);
		    return 0;
		}
		
		lCount=0;
		sprintf(sqlBuf,"select count(*) from msauser where ratelimit=%d ",qosid);
		tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
				if(tempCursor!=NULL){
						tempRow= ltDbFetchRow(tempCursor);
						if(tempRow!=NULL){
							lCount=atol(tempRow[0]);
						}
						ltDbCloseCursor(tempCursor);
				}
		if(lCount>0){
			 ltMsgPk->msgpktype=1;
				lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=uft-8\n",
			"lthtml",LT_TYPE_STRING,"<html><body bgcolor=\"#cccccc\" >警告: 该通道已经应用于用户,不能删除!</body></html>");
				ltMsgFree(ltMsgPk);
		    return 0;
		}
		
		sprintf(sqlBuf,"delete from msaqos where sid=%d ",qosid);
	  ltDbExecSql(G_DbCon,sqlBuf);
		ltqosdownlink(confd,ltMsgPk,lt_MMHead);
	  return 0;
	}else if( strcmp(edittype,"APP")==0){
			ltqosdownlink(confd,ltMsgPk,lt_MMHead);
			return 0;
	}


	if(_bcKernelHead->banddownlink<1){
		ltbandlink(confd,ltMsgPk,lt_MMHead);
		return 0;
	}

	ltqosdownlink(confd,ltMsgPk,lt_MMHead);
	return 0;


}
Ejemplo n.º 18
0
/*修改服务和特征*/
int ltsaveurlsort(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
	   char sqlBuf[1024];
		 char *casrvid;
		 
 		 char *camatchDirect;
 		 char *camatchAgree;
 		 char *camatchload;
 		 char *camatchportL;
 		 char *camatchportT;
 		 char *cadescmatch1;
 		 char *cadescmatch2;
 		 char *cadescmatch3;
 		 
 		 char *caflag;
	   
	   char *casrvname;
	   char *casrvdesc;
 		 char *cadenytype;
	   char *calevel;
	   
	   char caMsg[256];
		 
		 char *dbUser;
		 char *dbPass;
		 char *dbName;
		 dbName=_ltPubInfo->_dbname;
		 dbUser=_ltPubInfo->_dbuser;
		 dbPass=_ltPubInfo->_dbpass;
		 G_DbCon=ltDbConnect(dbUser,dbPass,dbName);
		 if(G_DbCon==NULL){
				ltMsgPk->msgpktype=1;
				lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: application/json\n","lthtml",LT_TYPE_STRING,"");
				ltMsgFree(ltMsgPk);			
				return 0;
		 }
    casrvid=ltMsgGetVar_s(ltMsgPk,"srvid");
    
		camatchDirect=ltMsgGetVar_s(ltMsgPk,"matchDirect");
		camatchAgree=ltMsgGetVar_s(ltMsgPk,"matchAgree");
		camatchportL=ltMsgGetVar_s(ltMsgPk,"matchportL");
		camatchportT=ltMsgGetVar_s(ltMsgPk,"matchportT");
		camatchload=ltMsgGetVar_s(ltMsgPk,"matchload");
		
		cadescmatch1=ltMsgGetVar_s(ltMsgPk,"srvdescmatch1");
		cadescmatch2=ltMsgGetVar_s(ltMsgPk,"srvdescmatch2");
		cadescmatch3=ltMsgGetVar_s(ltMsgPk,"srvdescmatch3");
		
		casrvname=ltMsgGetVar_s(ltMsgPk,"srvname");
		casrvdesc=ltMsgGetVar_s(ltMsgPk,"srvdesc");
		cadenytype=ltMsgGetVar_s(ltMsgPk,"denytype");
		calevel=ltMsgGetVar_s(ltMsgPk,"level");
		
		caflag=ltMsgGetVar_s(ltMsgPk,"flag");

printf("123casrvid:%s\n",casrvid);		
    //根据传的参数判断
    if(atoi(caflag)==0){
		  //sprintf(sqlBuf,"update nassrv set matchDirect='%s',matchAgree='%s',matchportL='%s',matchportT='%s',matchload='%s',srvdescmatch1='%s',srvdescmatch2='%s',srvdescmatch3='%s' where srvid='%s'",camatchDirect,camatchAgree,camatchportL,camatchportT,camatchload,cadescmatch1,cadescmatch2,cadescmatch3,casrvid);	  
		  //ltDbExecSql(G_DbCon,sqlBuf);
	  	
		  char pFile[512];
		  if(casrvid==NULL){
		   	sprintf(pFile,"/etc/msa/msa/srvlist/srvdefine/-1");
		 	}else{
		   	sprintf(pFile,"/etc/msa/msa/srvlist/srvdefine/%s",casrvid);
		  }  
		  char    caCmdCon[2048];
	    sprintf(caCmdCon,"echo '%s%s%s%s%s%s%s%s' > %s",camatchAgree,camatchDirect,camatchportL,camatchportT,camatchload,cadescmatch1,cadescmatch2,cadescmatch3,pFile);
	    system(caCmdCon);
	    
		  snprintf(caMsg,255,"%s","update nassrv srvType success.");
			logWrite(ltMsgPk,caMsg,3);
		}else if(atoi(caflag)==1){
		  sprintf(sqlBuf,"update nassrv set denytype='%s',srvname='%s',srvdesc='%s',level='%s' where srvid='%s'",cadenytype,casrvname,casrvdesc,calevel,casrvid);	  
		  ltDbExecSql(G_DbCon,sqlBuf); 
		  snprintf(caMsg,255,"%s","update nassrv success.");
			logWrite(ltMsgPk,caMsg,3);
		}
printf("sqlBuf:%s\n",sqlBuf);	 
	  ltMsgPk->msgpktype=1;
    lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: application/json\n","lthtml",LT_TYPE_STRING,"0");
    ltMsgFree(ltMsgPk);
    return 0;
		

}
Ejemplo n.º 19
0
int ltbandlinkok(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
	
	
	char    *ENABLEBAND;
	char    *BANDUPLINK;
	char    *BANDDOWNLINK;
	char    *BANDUPDEF;
	char    *BANDDOWNDEF;
	char    caCmdCon[512];
	char    *pFile="/etc/msa/msa/qos/settings";

	ENABLEBAND="YES";
	
	BANDUPLINK=ltMsgGetVar_s(ltMsgPk,"BANDUPLINK");
	BANDDOWNLINK=ltMsgGetVar_s(ltMsgPk,"BANDDOWNLINK");

	if(ltStrIsDigital(BANDDOWNLINK)==0){
				_bcKernelHead->banddownlink=atol(BANDDOWNLINK);
	}
	if(ltStrIsDigital(BANDUPLINK)==0){
				_bcKernelHead->banduplink=atol(BANDUPLINK);
	}
	BANDUPDEF=ltMsgGetVar_s(ltMsgPk,"BANDUPDEF");
	BANDDOWNDEF=ltMsgGetVar_s(ltMsgPk,"BANDDOWNDEF");

	if(ltStrIsDigital(BANDDOWNDEF)==0){
				_bcKernelHead->banddowndef=atol(BANDDOWNDEF)*1000;
	}
	if(ltStrIsDigital(BANDUPDEF)==0){
				_bcKernelHead->bandupdef=atol(BANDUPDEF)*1000;
	}
	
	if(_bcKernelHead->banddownlink<10 || _bcKernelHead->banduplink<10 ){
		ENABLEBAND="NO";
	}
	
	system("/bin/cp /etc/msa/msa/qos/settings /etc/msa/msa/qos/settings.old");
		/*连接方式*/
	
	
	sprintf(caCmdCon,"echo 's%08llu%08llu' > /proc/baochuang/rshaper",atoll(BANDUPLINK),atoll(BANDDOWNLINK));
	system(caCmdCon);
	
	sprintf(caCmdCon,"echo 'ENABLEBAND=%s' > %s",ENABLEBAND,pFile);
	system(caCmdCon);
		
	sprintf(caCmdCon,"echo 'BANDUPLINK=%s' >> %s",BANDUPLINK,pFile);
	system(caCmdCon);
	
	sprintf(caCmdCon,"echo 'BANDDOWNLINK=%s' >> %s",BANDDOWNLINK,pFile);
	system(caCmdCon);
	
	sprintf(caCmdCon,"echo 'BANDDOWNDEF=%s' >> %s",BANDDOWNDEF,pFile);
	system(caCmdCon);
	
	sprintf(caCmdCon,"echo 'BANDUPDEF=%s' >> %s",BANDUPDEF,pFile);
	system(caCmdCon);
	
		
	ltbandlink(confd,ltMsgPk,lt_MMHead);
	
  return 0;

}
Ejemplo n.º 20
0
/*修改IP 域名*/
int msaUpdateType(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
	   char *casrvid;
		 char *cadenytype;
		 char *casrvip;
		 char *casrvarea;
		 char *caflag;
	   char caMsg[256];
		 
		 char *dbUser;
		 char *dbPass;
		 char *dbName;
		 dbName=_ltPubInfo->_dbname;
		 dbUser=_ltPubInfo->_dbuser;
		 dbPass=_ltPubInfo->_dbpass;
		 G_DbCon=ltDbConnect(dbUser,dbPass,dbName);
		 if(G_DbCon==NULL){
				ltMsgPk->msgpktype=1;
				lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: application/json\n","lthtml",LT_TYPE_STRING,"");
				ltMsgFree(ltMsgPk);			
				return 0;
		 }
		casrvid=ltMsgGetVar_s(ltMsgPk,"srvid");//my_id
    cadenytype=ltMsgGetVar_s(ltMsgPk,"denytype");
    casrvip=ltMsgGetVar_s(ltMsgPk,"srvip");
    casrvarea=ltMsgGetVar_s(ltMsgPk,"srvarea");
    caflag=ltMsgGetVar_s(ltMsgPk,"flag");
//printf("casrvid:%s\n",casrvid);
		if(atoi(caflag)==1){
			//修改IP
			char pFile[512];
			if(casrvid!=NULL){
		   		sprintf(pFile,"/etc/msa/msa/srvlist/diplist/%s",casrvid);
		 	}else{
		   		sprintf(pFile,"/etc/msa/msa/srvlist/diplist/1");
		  }
			printf("pFile:%s\n",pFile);
	    char    *srvip;
		  char    caCmdCon[2048];
		  srvip=ltMsgGetVar_s(ltMsgPk,"srvip");

	    sprintf(caCmdCon,"echo '%s' > %s",srvip,pFile);
	    system(caCmdCon);
	    
		  snprintf(caMsg,255,"%s","update nassrv IP success.");
		  logWrite(ltMsgPk,caMsg,3);
		  ltMsgPk->msgpktype=1;
	    lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: application/json\n","lthtml",LT_TYPE_STRING,"0");
	    ltMsgFree(ltMsgPk);
	  	return 0;
  	}else if(atoi(caflag)==2){
			//修改域名
			char pFile[512];
			if(casrvid!=NULL){
		   		sprintf(pFile,"/etc/msa/msa/srvlist/urllist/%s",casrvid);
		 	}else{
		   		sprintf(pFile,"/etc/msa/msa/srvlist/urllist/1");
		  }
	    char    *srvarea;
		  char    caCmdCon[2048];
		  srvarea=ltMsgGetVar_s(ltMsgPk,"srvarea");
		  
	    sprintf(caCmdCon,"echo '%s' > %s",srvarea,pFile);
	    system(caCmdCon); 
	    
		  snprintf(caMsg,255,"%s","update nassrv domain success.");
		  logWrite(ltMsgPk,caMsg,3);
		  ltMsgPk->msgpktype=1;
	    lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: application/json\n","lthtml",LT_TYPE_STRING,"0");
	    ltMsgFree(ltMsgPk);
	  	return 0;
  	}
  ltMsgPk->msgpktype=1;
  lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: application/json\n","lthtml",LT_TYPE_STRING,"1");
  ltMsgFree(ltMsgPk);
	return 0;
}
Ejemplo n.º 21
0
int msaReportWebLineAjaxSubmit(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead)

{

    ltDbCursor  *tempCursor;

    LT_DBROW    tempRow;

    ltDbHeadPtr dbPtr;

    ltTablePtr  tablePtr;

    char sqlBuf[1024];

    char caSdate[32],caEdate[32],caSdate1[32],caSdate2[32];

    char *reportname=NULL;

    char *email=NULL;

    char *lt_page_content=NULL;

    char *work=NULL;

    char caTempDir[256];

    char responseDir[256];

    char caLabel[256];

    char strdayflow[32];

    char htmlpage[256];

    unsigned long long lMaxBytes=1;

    unsigned long tmpDir=0;

    unsigned long fileName=0;

    long lTime,lTime1,lTime2;

    int  iFd=-1;

    int  srvindex,step;

    step=0;

    memset(htmlpage,0,sizeof(htmlpage));

    memset(caLabel,0,sizeof(caLabel));

    memset(caTempDir,0,sizeof(caTempDir));

    memset(responseDir,0,sizeof(responseDir));

    char *dbUser;

    char *dbPass;

    char *dbName;

    dbName=_ltPubInfo->_dbname;

    dbUser=_ltPubInfo->_dbuser;

    dbPass=_ltPubInfo->_dbpass;

    G_DbCon=ltDbConnect(dbUser,dbPass,dbName);

    if(G_DbCon==NULL) {

        return 0;

    }

    if(ltMsgGetVar_s(ltMsgPk,"sdate")) {

        sprintf(caSdate,"%s",ltMsgGetVar_s(ltMsgPk,"sdate"));

    } else {

        sprintf(caSdate,"%s","");

    }

    if(ltMsgGetVar_s(ltMsgPk,"edate")) {

        sprintf(caEdate,"%s",ltMsgGetVar_s(ltMsgPk,"edate"));

    } else {

        sprintf(caEdate,"%s","");

    }

    if(ltMsgGetVar_s(ltMsgPk,"reportname")) {

        reportname=ltMsgGetVar_s(ltMsgPk,"reportname");

    }

    if(ltMsgGetVar_s(ltMsgPk,"email")) {

        email=ltMsgGetVar_s(ltMsgPk,"email");

    }

    if(ltMsgGetVar_s(ltMsgPk,"step")) {

        step=atoi(ltMsgGetVar_s(ltMsgPk,"step"));

    }

    if(ltMsgGetVar_s(ltMsgPk,"work")) {

        work=ltMsgGetVar_s(ltMsgPk,"work");

    }

    if(ltMsgGetVar_s(ltMsgPk,"filedir")) {

        fileName=atoll(ltMsgGetVar_s(ltMsgPk,"filedir"));

    }

    if(fileName==0) {

        tmpDir=ltStrGetId();

        sprintf(caTempDir,"%s%s/%lu/",_datacenterdir,_webreport,tmpDir);

        sprintf(responseDir,"%lu",tmpDir);

        printf("caTempDir:%s\n",caTempDir);

        if(ltFileIsExist(caTempDir)!=1) {

            if(mkdir(caTempDir,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)!=0) {

                ltMsgPk->msgpktype=1;

                lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\n","lthtml",LT_TYPE_STRING,"0");

                ltMsgFree(ltMsgPk);

                return 0;

            }

        }

    } else {

        sprintf(caTempDir,"%s%s/%lu/",_datacenterdir,_webreport,fileName);

        sprintf(responseDir,"%lu",fileName);

    }



    lTime = time(0);

    if(!ltStrIsSpaces(caSdate)) {

        lTime1 = nasCvtLongTime(caSdate,"00:00:00");

    } else {

        lTime1 = 0;

    }

    if(!ltStrIsSpaces(caEdate)) {

        lTime2 = nasCvtLongTime(caEdate,"23:59:59");

    } else {

        lTime2 = 0;

    }



    if(lTime1 == 0) {

        lTime1 = lTime;

    }

    if(lTime2 == 0) {

        lTime2 = lTime;

    }

    if(lTime1 > lTime) {

        lTime1 = lTime;

    }

    if(lTime2>lTime) {

        lTime2=lTime;

    }



    char sDate[64],sTime[64];

    char caFile1[256];

    char caCmd[256];

    int  fdwrite=0;

    nasTimeGetDate(caSdate1,lTime);

    nasCvtStime(time(0),sDate,sTime);

    sprintf(caFile1,"%sinfo.ini",caTempDir);

    fdwrite = open(caFile1, O_APPEND | O_WRONLY | O_CREAT, 0644);

    if(fdwrite == (-1)) {

        ltMsgPk->msgpktype=1;

        lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\n","lthtml",LT_TYPE_STRING,"0");

        ltMsgFree(ltMsgPk);

        return 0;

    }

    sprintf(caCmd,"date=%s_%s\n",sDate,sTime);

    write(fdwrite,caCmd,strlen(caCmd));

    sprintf(caCmd,"reportname=%s\n",reportname);

    write(fdwrite,caCmd,strlen(caCmd));

    close(fdwrite);

    sprintf(caLabel,"/bin/echo '1' > %sproccess.ini",caTempDir);

    system(caLabel);

    sprintf(caLabel,"/bin/cp %s%s/right-top-d.jpg  %s",_msahtmldir,_weblineplt,caTempDir);

    system(caLabel);

    sprintf(caLabel,"/bin/cp %s%s/right-top.jpg  %s",_msahtmldir,_weblineplt,caTempDir);

    system(caLabel);

    sprintf(caLabel,"/bin/cp %s%s/banner.jpg  %s",_msahtmldir,_weblineplt,caTempDir);

    system(caLabel);

    sprintf(caLabel,"/bin/cp %s%s/up-1.jpg  %s",_msahtmldir,_weblineplt,caTempDir);

    system(caLabel);

    sprintf(caLabel,"/bin/cp %s%s/up-2.jpg  %s",_msahtmldir,_weblineplt,caTempDir);

    system(caLabel);

    sprintf(caLabel,"/bin/cp %s%s/up-3.jpg  %s",_msahtmldir,_weblineplt,caTempDir);

    system(caLabel);



    ltMsgPk->msgpktype=1;

    lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\n","lthtml",LT_TYPE_STRING,responseDir);

    nasTimeGetDate(caSdate1,lTime1);

    nasTimeGetDate(caSdate2,lTime2);

    if(step==1) {									//网址分类排序

        sprintf(sqlBuf,"select urlsort,sum(bytes) as abyte  from msahttpreport where sdate>='%s' and sdate<='%s' and workflag=%s group by urlsort order by abyte desc ",caSdate1,caSdate2,work);

    } else if(step==2) {						//网址流量排序

        sprintf(sqlBuf,"select host,sum(bytes) as abyte,sum(lcount) as acount,sum(ctime) as ctime from msauserhttpreport where sdate>='%s' and sdate<='%s' and workflag=%s group by host order by abyte asc",caSdate1,caSdate2,work);

    } else if(step==3) {						//top30流量人员网址访问

        sprintf(sqlBuf,"select host,sum(bytes) as abyte,sum(lcount) as acount,sum(ctime) as ctime from msauserhttpreport where sdate>='%s' and sdate<='%s' and workflag=%s group by host order by abyte asc limit %d offset 0",caSdate1,caSdate2,work,30);

    } else if(step==4) {						//网址访问次数排序

        sprintf(sqlBuf,"select host,sum(bytes) as abyte,sum(lcount) as acount,sum(ctime) as ctime from msahttpreport where sdate>='%s' and sdate<='%s' and workflag=%s group by host order by acount desc",caSdate1,caSdate2,work);

    } else if(step==5) {						//网址分类访问次数排序

        sprintf(sqlBuf,"select urlsort,sum(bytes) as abyte,sum(lcount) as acount  from msahttpreport where sdate>='%s' and sdate<='%s' and workflag=%s group by urlsort order by acount desc ",caSdate1,caSdate2,work);

    }

    printf("sql:%s\n",sqlBuf);

    tempCursor = ltDbOpenCursor(G_DbCon,sqlBuf);

    if(tempCursor == NULL) {

        sprintf(caLabel,"/bin/echo '%s' > %serrmsg.ini","数据库错误,无法生成报告",caTempDir);

        system(caLabel);

        ltMsgFree(ltMsgPk);

        return 0;

    }



    srvindex=1;

    lMaxBytes=1;

    dbPtr=lt_dbinit();

    lt_db_htmlpage(dbPtr,"utf-8");

    tablePtr=lt_dbput_table(dbPtr,"list");

    tempRow= ltDbFetchRow(tempCursor);

    while(tempRow!=NULL) {

        if(step==1) {

            if(atoll(tempRow[1])>1024000) {

                sprintf(strdayflow,"%0.3fM",atoll(tempRow[1])/1024000.00);

            } else {

                sprintf(strdayflow,"%0.3fKB",atoll(tempRow[1])/1024.00);

            }

            lt_dbput_recordvars(tablePtr,2,

                                "urlsort",LT_TYPE_STRING,_ltPubInfo->ltService[atol(tempRow[0])].srvName,

                                "lbyte",LT_TYPE_STRING,strdayflow

                               );

            printf("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n");

        } else if(step==2) {

            if(atoll(tempRow[1])>1024000) {

                sprintf(strdayflow,"%0.3fM",atoll(tempRow[1])/1024000.00);

            } else {

                sprintf(strdayflow,"%0.3fKB",atoll(tempRow[1])/1024.00);

            }

            lt_dbput_recordvars(tablePtr,2,

                                "host",LT_TYPE_STRING,tempRow[0],

                                "lbyte",LT_TYPE_STRING,strdayflow

                               );

        } else if(step==3) {

            if(atoll(tempRow[1])>1024000) {

                sprintf(strdayflow,"%0.3fM",atoll(tempRow[1])/1024000.00);

            } else {

                sprintf(strdayflow,"%0.3fK",atoll(tempRow[1])/1024.00);

            }

//						if(lMaxBytes<atoll(tempRow[1])){

//		         		lMaxBytes=atoll(tempRow[1]);

//		        }



            lt_dbput_recordvars(tablePtr,4,

                                "host",LT_TYPE_STRING,tempRow[0],

                                "srvljflow",LT_TYPE_STRING,strdayflow,

                                "srvlcount",LT_TYPE_STRING,tempRow[2],

                                "srvljtime",LT_TYPE_STRING,time2str(atoi(tempRow[3]))

                               );

        } else if(step==4) {

            if(atoll(tempRow[1])>1024000) {

                sprintf(strdayflow,"%0.3fM",atoll(tempRow[1])/1024000.00);

            } else {

                sprintf(strdayflow,"%0.3fK",atoll(tempRow[1])/1024.00);

            }

            if(lMaxBytes<atoll(tempRow[1])) {

                lMaxBytes=atoll(tempRow[1]);

            }



            lt_dbput_recordvars(tablePtr,4,

                                "host",LT_TYPE_STRING,tempRow[0],

                                "srvljflow",LT_TYPE_STRING,strdayflow,

                                "srvlcount",LT_TYPE_STRING,tempRow[2],

                                "srvljtime",LT_TYPE_STRING,time2str(atoi(tempRow[3]))

                               );

        } else if(step==5) {

            if(atoll(tempRow[1])>1024000) {

                sprintf(strdayflow,"%0.3fM",atoll(tempRow[1])/1024000.00);

            } else {

                sprintf(strdayflow,"%0.3fK",atoll(tempRow[1])/1024.00);

            }

            if(lMaxBytes<atoll(tempRow[1])) {

                lMaxBytes=atoll(tempRow[1]);

            }

            lt_dbput_recordvars(tablePtr,3,

                                "sorname",LT_TYPE_STRING,_ltPubInfo->ltService[atol(tempRow[0])].srvName,

                                "srvljflow",LT_TYPE_STRING,strdayflow,

                                "srvlcount",LT_TYPE_STRING,tempRow[2]

                               );

        }

        if(step==1) {

            srvindex++;

        }

        tempRow=ltDbFetchRow(tempCursor);//移动光标

    }

    ltDbCloseCursor(tempCursor);

//    if(step==1){//画图

//			  close(iFd);

//			  sprintf(caLabel,"%s/Scripts/onlinesrv-bar.pl  %sdata.ini %ssrvreport.gif %llu ",_msahtmldir,caTempDir,caTempDir,lMaxBytes);  //柱状 饼图:onlinesrv1.pl

//			  system(caLabel);

//			  lt_dbput_rootvars(dbPtr,1,"piechart","srvreport.gif" );

//	  }

    lt_dbput_rootvars(dbPtr,3,"reportname",reportname,"bdate",caSdate1,"edate",caSdate2);

    sprintf(htmlpage,"%s%s/webflow%d.htm",_msahtmldir,_weblineplt,step);

    printf("%s\n",htmlpage);

    lt_page_content=ltPltFileParse(htmlpage,dbPtr->doc,0);

    if(lt_page_content==NULL) {

        printf("11111111111111111111111111\n");

        sprintf(caLabel,"/bin/echo '%s' > %serrmsg.ini","无报告数据,无法生成报告",caTempDir);

        system(caLabel);/*建立目录和正在处理标志*/

        ltMsgFree(ltMsgPk);

        lt_dbfree(dbPtr);

        return 0;

    } else {

        printf("22222222222222222222222222\n");

        lt_page_content=strstr(lt_page_content,"<!DOCTYPE");

        if(step==1) {

            sprintf(caLabel,"%sindex.htm",caTempDir);

        } else {

            sprintf(caLabel,"%spage%d.htm",caTempDir,step);

        }

        iFd = open(caLabel,O_WRONLY | O_NDELAY | O_TRUNC | O_CREAT,0644);

        if(iFd >0) {

            write(iFd,lt_page_content,strlen(lt_page_content));

        }

        close(iFd);

    }



    if(step==5) {

        sprintf(caLabel,"%s/Scripts/html2mail  %s index.htm %sindex.mht report %s",_msahtmldir,caTempDir,caTempDir,email);

        system(caLabel);

    }

    chdir(caTempDir);

    system("rm -f report.tgz");

    system("tar -cvzf report.tgz *");

    sprintf(caLabel,"/bin/rm  %sproccess.ini",caTempDir);

    system(caLabel);

    sprintf(caLabel,"/bin/rm  %serrmsg.ini",caTempDir);

    system(caLabel);

    ltMsgFree(ltMsgPk);

    lt_dbfree(dbPtr);

    return 0;

}
Ejemplo n.º 22
0
int ltupdatejjr(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
   char sqlBuf[1024];
   char caMsg[256];
   char mytime1[200];
   char mytime2[200];
   
   char *dbUser;
	 char *dbPass;
	 char *dbName;
	 dbName=_ltPubInfo->_dbname;
	 dbUser=_ltPubInfo->_dbuser;
	 dbPass=_ltPubInfo->_dbpass;
	 G_DbCon=ltDbConnect(dbUser,dbPass,dbName);
	 if(G_DbCon==NULL){
							ltMsgPk->msgpktype=1;
							lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html\n","lthtml",LT_TYPE_STRING,"");
							ltMsgFree(ltMsgPk);			
							return 0;
	 }
   
   memset(mytime1,0,sizeof(mytime1));
   memset(mytime2,0,sizeof(mytime2));
   memcpy(mytime1,ltMsgGetVar_s(ltMsgPk,"jjrtime"),198);
   memcpy(mytime2,ltMsgGetVar_s(ltMsgPk,"jjrtime")+198,198);
   sprintf(sqlBuf,"update nasjjr set jjrname='%s',jjrdesc='%s',jjrtime='%s',jjrtime1='%s' where jjrid=%s",
                      ltMsgGetVar_s(ltMsgPk,"jjrname"),
                      ltMsgGetVar_s(ltMsgPk,"jjrdesc"),
                      mytime1,mytime2,
                      ltMsgGetVar_s(ltMsgPk,"jjrid"));
   ltDbExecSql(G_DbCon,sqlBuf); 
           
	 strcpy(_ltPubInfo->_jjrtimelist[atol(ltMsgGetVar_s(ltMsgPk,"jjrid"))].jjrname,ltMsgGetVar_s(ltMsgPk,"jjrname"));
	 strcpy(_ltPubInfo->_jjrtimelist[atol(ltMsgGetVar_s(ltMsgPk,"jjrid"))].jjrdesc,ltMsgGetVar_s(ltMsgPk,"jjrdesc"));
	 strcpy(_ltPubInfo->_jjrtimelist[atol(ltMsgGetVar_s(ltMsgPk,"jjrid"))].jjrtime,ltMsgGetVar_s(ltMsgPk,"jjrtime"));
		
   snprintf(caMsg,255,"%s","update nasjjr success.");
	 logWrite(ltMsgPk,caMsg,3);
	 ltDbClose(G_DbCon);
   ltjjrinfolist(confd,ltMsgPk,lt_MMHead);
   return 0;
}
Ejemplo n.º 23
0
//显示规则修改
int showEditServiceSimp(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
	//数据库连接
		  char *dbUser;
		  char *dbPass;
		  char *dbName;
		  dbName=_ltPubInfo->_dbname;
			dbUser=_ltPubInfo->_dbuser;
			dbPass=_ltPubInfo->_dbpass;
			G_DbCon=ltDbConnect(dbUser,dbPass,dbName);
			if(G_DbCon!=NULL){
				//printf("db connect ok\n");
			}else{
				fprintf(stderr,"db connect error\n");
			}
	 char group[1001];
	 char sqlBuf[128];
	 int myratelimit,ruleschedule,rulejjr,grouptype;
	 char str[16];
	 myratelimit=-1;
	 ruleschedule=-1;
	 rulejjr=-1;
	 grouptype=0;
	 ltDbHeadPtr dbPtr;
	 ltTablePtr  tablePtr;
   dbPtr=lt_dbinit();
   lt_db_htmlpage(dbPtr,"utf-8");
   lt_dbput_rootvars(dbPtr,1,"ruleid",ltMsgGetVar_s(ltMsgPk,"sid"));
	 LT_DBROW tempRow;
	 ltDbCursor *tempCursor;
	 memset(sqlBuf,0,sizeof(sqlBuf));
	 sprintf(sqlBuf,"select * from nassrvrule where ruleid=%s",ltMsgGetVar_s(ltMsgPk,"sid"));
	 tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
						if(tempCursor){
							tempRow= ltDbFetchRow(tempCursor);
							if(tempRow){
								memset(group,0,sizeof(group));
								sprintf(group,"%s%s%s%s",tempRow[5],tempRow[6],tempRow[7],tempRow[8]);

								memset(str,0,sizeof(str));
								sprintf(str,"ruleflag%s",tempRow[2]);
								lt_dbput_rootvars(dbPtr,1,str,"selected");
								memset(str,0,sizeof(str));
								sprintf(str,"logaction%s",tempRow[10]);
								lt_dbput_rootvars(dbPtr,1,str,"selected");
								memset(str,0,sizeof(str));
								sprintf(str,"conaction%s",tempRow[11]);
								lt_dbput_rootvars(dbPtr,1,str,"selected");
								lt_dbput_rootvars(dbPtr,5,
			       	 		"rulename",tempRow[1],
			       	 		"policy",tempRow[9],
			       	 		"group",group,
			       	 		"ruleurl",tempRow[13]
       	 				);
       	 				ruleschedule=atoi(tempRow[3]);
       	 				rulejjr=atoi(tempRow[4]);
							}
							ltDbCloseCursor(tempCursor);
						}
						char schedulesel[32];
						char jjrsel[32];
		int i;
		i=0;
		char strid[8];
		memset(strid,0,sizeof(strid));
		tablePtr=lt_dbput_table(dbPtr,"jjrlist");
		for(i=0;i<NAS_MAXJJR_NUM;i++){
				sprintf(strid,"%d",_ltPubInfo->_jjrtimelist[i].jjrid);
				if(strcmp(_ltPubInfo->_jjrtimelist[i].jjrname,"")!=0){
					memset(jjrsel,0,sizeof(jjrsel));
					if(_ltPubInfo->_jjrtimelist[i].jjrid==rulejjr){
							sprintf(jjrsel,"%s","selected");
					}
					lt_dbput_recordvars(tablePtr,3,
					  "jjrid",LT_TYPE_STRING,strid,
					  "jjrsel",LT_TYPE_STRING,jjrsel,
						"jjrname",LT_TYPE_STRING,_ltPubInfo->_jjrtimelist[i].jjrname);
				}
		}
		tablePtr=lt_dbput_table(dbPtr,"schlist");
		memset(strid,0,sizeof(strid));
		for(i=0;i<NAS_MAXSCH_NUM;i++){
				sprintf(strid,"%d",_ltPubInfo->_schtimelist[i].schid);
				if(strcmp(_ltPubInfo->_schtimelist[i].schname,"")!=0){
					memset(schedulesel,0,sizeof(schedulesel));
					if(_ltPubInfo->_schtimelist[i].schid==ruleschedule){
													sprintf(schedulesel,"%s","selected");
					}
					lt_dbput_recordvars(tablePtr,3,
					  "schid",LT_TYPE_STRING,strid,
					  "schsel",LT_TYPE_STRING,schedulesel,
						"schname",LT_TYPE_STRING,_ltPubInfo->_schtimelist[i].schname);
				}
		}
	 ltDbClose(G_DbCon);
	 ltMsgPk->msgpktype=1;
   lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msa/htmlplt/rule/SrvRulelistinfoSimp.htm",dbPtr->head,0);
   ltMsgFree(ltMsgPk);
   lt_dbfree(dbPtr);
   return 0;
}
Ejemplo n.º 24
0
int ltaddsch(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
	 nasschtime _nasschtime[NAS_MAXSCH_NUM];
   char sqlBuf[1024];
	 ltDbCursor *tempCursor;
	 LT_DBROW tempRow;
   char caMsg[256];
   char mytime1[200];
   char mytime2[200];
   memset(mytime1,0,sizeof(mytime1));
   memset(mytime2,0,sizeof(mytime2));
   memcpy(mytime1,ltMsgGetVar_s(ltMsgPk,"schtime"),198);
   memcpy(mytime2,ltMsgGetVar_s(ltMsgPk,"schtime")+198,198);
   long lCount=0;
   
   char *dbUser;
	 char *dbPass;
	 char *dbName;
	 dbName=_ltPubInfo->_dbname;
	 dbUser=_ltPubInfo->_dbuser;
	 dbPass=_ltPubInfo->_dbpass;
	 G_DbCon=ltDbConnect(dbUser,dbPass,dbName);
	 if(G_DbCon==NULL){
				ltMsgPk->msgpktype=1;
				lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html\n","lthtml",LT_TYPE_STRING,"");
				ltMsgFree(ltMsgPk);			
				return 0;
	 }
   memset((void *)_nasschtime,0,sizeof(nasschtime)*NAS_MAXSCH_NUM);
   
   sprintf(sqlBuf,"select count(*) from nasschedule");
   tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
   if(tempCursor!=NULL){
          tempRow= ltDbFetchRow(tempCursor);
          if(tempRow!=NULL){
             lCount=atol(tempRow[0]);
          }
          ltDbCloseCursor(tempCursor);
   }
   if(lCount == 0) {
         lCount=1;
   }else{
    sprintf(sqlBuf,"select max(schid)+1 from nasschedule");
    lCount = 1;
    tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
    if(tempCursor!=NULL){
     tempRow= ltDbFetchRow(tempCursor);
     if(tempRow!=NULL){
               lCount=atol(tempRow[0]);
     }
     ltDbCloseCursor(tempCursor);
		}
   }       
    sprintf(sqlBuf,"insert into nasschedule values (%ld,'%s','%s','%s','%s')",lCount,
                      ltMsgGetVar_s(ltMsgPk,"schname"),
                      ltMsgGetVar_s(ltMsgPk,"schdesc"),
                      mytime1,mytime2);
    ltDbExecSql(G_DbCon,sqlBuf); 
    
		_ltPubInfo->_schtimelist[lCount].schid=lCount;
		strcpy(_ltPubInfo->_schtimelist[lCount].schname,ltMsgGetVar_s(ltMsgPk,"schname"));
		strcpy(_ltPubInfo->_schtimelist[lCount].schdesc,ltMsgGetVar_s(ltMsgPk,"schdesc"));
		strcpy(_ltPubInfo->_schtimelist[lCount].schtime,ltMsgGetVar_s(ltMsgPk,"schtime"));
		
		snprintf(caMsg,255,"%s","add nasschedule success.");
	  logWrite(ltMsgPk,caMsg,3);
	  ltDbClose(G_DbCon);
	  ltschinfolist(confd,ltMsgPk,lt_MMHead);
 return 0;
}
Ejemplo n.º 25
0
int msaReportFlowLineAjaxSubmit(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead)
{	
    ltDbCursor  *tempCursor;
    LT_DBROW    tempRow;
    ltDbHeadPtr dbPtr;
    ltTablePtr  tablePtr;   
    stralloc strTemp;  
    char        caSdate[32],caEdate[32],caSdate1[32],caSdate2[32];
		char        *reportname=NULL;
		char        *email=NULL;
		char        *lt_page_content=NULL;
		char        *gid=NULL;
		char        *work=NULL;
		char        caTempDir[256];  
		char        responseDir[256];
    char        caLabel[256];
    char        htmlpage[256];
    char        sqlBuf[1024]; 
    char        strdayflow[32];
    char        sDate[64],sTime[64];
	  char        caFile1[256];   
    char        caCmd[256];   
    char        atime[64];
    char        srvName[255];
    char 				caTmpp[2048];
    char 				flow[128];
   	long        lTime,lTime1,lTime2;
    int         iFd,srvindex,gindex,fdwrite,step,jjj;
    unsigned long long lMaxBytes;
    unsigned long tmpDir=0;
    unsigned long fileName=0;    
    step=0;
    strTemp.s=0;
	  jjj=0;
    memset(caTempDir,0,sizeof(caTempDir));
    memset(responseDir,0,sizeof(responseDir));
    memset(caLabel,0,sizeof(caLabel));
    memset(htmlpage,0,sizeof(htmlpage));
    memset(sqlBuf,0,sizeof(sqlBuf));
    memset(atime,0,sizeof(atime));
    memset(srvName,0,sizeof(srvName));
   	memset(caTmpp,0,sizeof(caTmpp));
   	memset(flow,0,sizeof(flow));

  	char *dbUser;
	  char *dbPass;
	  char *dbName;
	  dbName=_ltPubInfo->_dbname;
		dbUser=_ltPubInfo->_dbuser;
		dbPass=_ltPubInfo->_dbpass;
		G_DbCon=ltDbConnect(dbUser,dbPass,dbName);
		if(G_DbCon==NULL){
			return 0;
		}
		if(ltMsgGetVar_s(ltMsgPk,"sdate")){
	  	sprintf(caSdate,"%s",ltMsgGetVar_s(ltMsgPk,"sdate"));
	  }else{
	  	sprintf(caSdate,"%s","");
	  }
	  if(ltMsgGetVar_s(ltMsgPk,"edate")){
	  	 sprintf(caEdate,"%s",ltMsgGetVar_s(ltMsgPk,"edate"));
	  }else{
	  	 sprintf(caEdate,"%s","");
	  }
		if(ltMsgGetVar_s(ltMsgPk,"reportname")){		
	  	reportname=ltMsgGetVar_s(ltMsgPk,"reportname");
	  }
	  if(ltMsgGetVar_s(ltMsgPk,"email")){
	  	email=ltMsgGetVar_s(ltMsgPk,"email");
	  }
	  if(ltMsgGetVar_s(ltMsgPk,"step")){
	  	step=atoi(ltMsgGetVar_s(ltMsgPk,"step"));
	  }
    if(ltMsgGetVar_s(ltMsgPk,"gid")){
	  	gid=ltMsgGetVar_s(ltMsgPk,"gid");
	  		sprintf(caTmpp,"%s","");
				stralloc_cats(&strTemp,caTmpp);		
				int i;					
				for(i=0;i<1000;i++){
					if(gid[i]=='1'){
							jjj++;
						  if(jjj==1){
								sprintf(caTmpp,"%d",i); 
				        stralloc_cats(&strTemp,caTmpp);			
		          }else{
		            sprintf(caTmpp,",%d",i);  
				        stralloc_cats(&strTemp,caTmpp);				
		          }  					
					}	
				}
				stralloc_cats(&strTemp,"");
				stralloc_0(&strTemp); 
	  }
	  if(ltMsgGetVar_s(ltMsgPk,"filedir")){	  
	  	fileName=atoll(ltMsgGetVar_s(ltMsgPk,"filedir"));
	  }
		 if(ltMsgGetVar_s(ltMsgPk,"work")){	  
	  	work=ltMsgGetVar_s(ltMsgPk,"work");
	  }

    if(fileName==0){
		    tmpDir=ltStrGetId();
		    sprintf(caTempDir,"%s%s/%lu/",_datacenterdir,_flowreport,tmpDir);
		    sprintf(responseDir,"%lu",tmpDir);	  
		    if(ltFileIsExist(caTempDir)!=1) {
		       if(mkdir(caTempDir,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)!=0) {
				      ltMsgPk->msgpktype=1;
							lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\n","lthtml",LT_TYPE_STRING,"0");		
							ltMsgFree(ltMsgPk);
			        return 0;
		       }
		 		}  
    }else{			
    	  sprintf(caTempDir,"%s%s/%lu/",_datacenterdir,_flowreport,fileName);   
    	  sprintf(responseDir,"%lu",fileName);
    }    

    lTime = time(0);
    if(!ltStrIsSpaces(caSdate)) {
        lTime1 = nasCvtLongTime(caSdate,"00:00:00");
    }else{
        lTime1 = 0;
    } 
    if(!ltStrIsSpaces(caEdate)) {
        lTime2 = nasCvtLongTime(caEdate,"23:59:59");
    }else {
        lTime2 = 0;
    }   
    if(lTime1 == 0) {
         lTime1 = lTime;       
    }
	  if(lTime2 == 0) {
         lTime2 = lTime;
    }
	  if(lTime1 > lTime) {
         lTime1 = lTime;
    }
    if(lTime2>lTime){
		 		 lTime2=lTime;
	  }
	  fdwrite=-1;
	  if(step==1){
			  nasCvtStime(time(0),sDate,sTime); 
			  sprintf(caFile1,"%sinfo.ini",caTempDir);     
			  fdwrite = open(caFile1, O_APPEND | O_WRONLY | O_CREAT, 0644);
				if(fdwrite == (-1)) {
					 ltMsgPk->msgpktype=1;
					 lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\n","lthtml",LT_TYPE_STRING,"0");		
					 ltMsgFree(ltMsgPk);
					 return 0;
				}			
				sprintf(caCmd,"date=%s_%s\n",sDate,sTime);
			  write(fdwrite,caCmd,strlen(caCmd));
			  sprintf(caCmd,"reportname=%s\n",reportname);
			  write(fdwrite,caCmd,strlen(caCmd));
			  close(fdwrite);
			  sprintf(caLabel,"/bin/echo '1' > %sproccess.ini",caTempDir);
			  system(caLabel);
			  sprintf(caLabel,"/bin/cp %s%s/right-top-d.jpg  %s",_msahtmldir,_flowlineplt,caTempDir);
			  system(caLabel);
			  sprintf(caLabel,"/bin/cp %s%s/right-top.jpg  %s",_msahtmldir,_flowlineplt,caTempDir);
			  system(caLabel);
			  sprintf(caLabel,"/bin/cp %s%s/banner.jpg  %s",_msahtmldir,_flowlineplt,caTempDir);
			  system(caLabel);
			  sprintf(caLabel,"/bin/cp %s%s/up-1.jpg  %s",_msahtmldir,_flowlineplt,caTempDir);
			  system(caLabel);
			  sprintf(caLabel,"/bin/cp %s%s/up-2.jpg  %s",_msahtmldir,_flowlineplt,caTempDir);
			  system(caLabel);
				sprintf(caLabel,"/bin/cp %s%s/up-3.jpg  %s",_msahtmldir,_flowlineplt,caTempDir);
			  system(caLabel);    
   }

    ltMsgPk->msgpktype=1;
	  lt_TcpResponse(confd,ltMsgPk,2,"lthead",LT_TYPE_STRING,"Content-type: text/html; charset=utf-8\n","lthtml",LT_TYPE_STRING,responseDir);		      
    nasTimeGetDate(caSdate1,lTime1);
    nasTimeGetDate(caSdate2,lTime2);
    if(step==1){							//服务流量报告
      sprintf(sqlBuf,"select service,sum(onlinetime) as acount,sum(bytes) as abyte from msasrvreport where sdate>='%s' and sdate<='%s' and workflag=%s group by service order by abyte desc ",caSdate1,caSdate2,work); 
    }else if(step==2){				//部门流量排序
    	sprintf(sqlBuf,"select c.name,sum(bytes)   as abyte from msasrvreport a,msauser b ,msagroup c where sdate>='%s' and sdate<='%s' and a.userid=b.userid and b.groupid0=c.id  and c.id in(%s) and workflag=%s group by c.name order by abyte desc",caSdate1,caSdate2,strTemp.s,work);    	      	       
    }else if(step==3){				//人员流量排序
			sprintf(sqlBuf,"select b.dispname,sum(bytes) as abyte from msasrvreport a,msauser b ,msagroup c where sdate>='%s' and sdate<='%s' and a.userid=b.userid and b.groupid0=c.id  and c.id in(%s) and workflag=%s group by b.dispname order by abyte desc",caSdate1,caSdate2,strTemp.s,work);
    }else if(step==4){				//网站流量排序
      sprintf(sqlBuf,"select host,sum(bytes)       as abyte from msauserhttpreport where sdate >= '%s' and sdate <= '%s' group by host order by abyte desc",caSdate1,caSdate2);			   
    }else{										//目的地址流量排序
    	 sprintf(sqlBuf,"select dip,sum(bytes)       as abyte from msaDipReport where sdate >= '%s' and sdate <= '%s' group by dip order by abyte desc ",caSdate1,caSdate2);
    }
	  printf("sql: %s\n",sqlBuf);
	  tempCursor = ltDbOpenCursor(G_DbCon,sqlBuf);
	  if(tempCursor == NULL){
		      sprintf(caLabel,"/bin/echo '%s' > %serrmsg.ini","数据库错误,无法生成报告",caTempDir); 
	    	  system(caLabel);
	    	  ltMsgFree(ltMsgPk); 
	        return 0;
	  }
		iFd=-1;
	  if(step==1){
		   sprintf(caLabel,"%sdata.ini",caTempDir);
	      iFd = open(caLabel,O_WRONLY | O_CREAT | O_TRUNC);
		    if(iFd == (-1)){
						sprintf(caLabel,"/bin/echo '%s' > %serrmsg.ini","无法建立数据文件",caTempDir);
			    	system(caLabel);
			      ltDbCloseCursor(tempCursor);
			      ltMsgFree(ltMsgPk);
			      return 0;
			 }							
	  }
	  
	  srvindex=1;
	  lMaxBytes=1;
	  gindex=0;
	  dbPtr=lt_dbinit();
    lt_db_htmlpage(dbPtr,"utf-8");  
    tablePtr=lt_dbput_table(dbPtr,"list"); 
	  tempRow= ltDbFetchRow(tempCursor);   
	  while(tempRow!=NULL){	      	                         	  
					if(step==1){										//服务流量报告
		   		  if(atoll(tempRow[2])>1024000){
					      sprintf(strdayflow,"%0.3fM",atoll(tempRow[2])/1024000.00);
					  }else{
					      sprintf(strdayflow,"%0.3fK",atoll(tempRow[2])/1024.00);
					  }			  
					  sprintf(caLabel,"%d,%lld\r\n",srvindex,atoll(tempRow[2]));
	          write(iFd, caLabel, strlen(caLabel));	
	          if(lMaxBytes<atoll(tempRow[2])){
	 		     		 lMaxBytes=atoll(tempRow[2]);
	          }						  	
				  	sprintf(srvName,"No%d:%s",srvindex,_ltPubInfo->topSrvName[atol(tempRow[0])].srvname);				  
						lt_dbput_recordvars(tablePtr,3,
							"srvname",LT_TYPE_STRING,srvName,  
			   			"srvljtime",LT_TYPE_STRING,tempRow[1],
			   			"srvljflow",LT_TYPE_STRING,strdayflow
		   		  ); 
					}else if(step==2){							//部门流量排序
						if(atoll(tempRow[1])>1024000){
               sprintf(flow,"%0.3fM",atoll(tempRow[1])/1024000.00);
            }else{
               sprintf(flow,"%0.3fKB",atoll(tempRow[1])/1024.00);
            }
             
		  	  	lt_dbput_recordvars(tablePtr,2,
							"groupname",LT_TYPE_STRING,tempRow[0],  
			   			"lbyte",LT_TYPE_STRING,flow
	   		    ); 	

					}else if(step==3){							//人员流量排序
						
						if(atoll(tempRow[1])>1024000){
               sprintf(flow,"%0.3fM",atoll(tempRow[1])/1024000.00);
            }else{
               sprintf(flow,"%0.3fKB",atoll(tempRow[1])/1024.00);
            }
	  	  	  lt_dbput_recordvars(tablePtr,2,
							"uname",LT_TYPE_STRING,tempRow[0],  
			   			"lbyte",LT_TYPE_STRING,flow
	   		    ); 	
		   		  
					}else if(step==4){							//网站流量排序
						if(atoll(tempRow[1])>1024000){
               sprintf(flow,"%0.3fM",atoll(tempRow[1])/1024000.00);
            }else{
               sprintf(flow,"%0.3fKB",atoll(tempRow[1])/1024.00);
            }
	  	  	  lt_dbput_recordvars(tablePtr,2,
							"host",LT_TYPE_STRING,tempRow[0],  
			   			"lbyte",LT_TYPE_STRING,flow
	   		    );
					}else{													//目的地址流量排序
						if(atoll(tempRow[1])>1024000){
               sprintf(flow,"%0.3fM",atoll(tempRow[1])/1024000.00);
            }else{
               sprintf(flow,"%0.3fKB",atoll(tempRow[1])/1024.00);
            }
	  	  	  lt_dbput_recordvars(tablePtr,2,
							"dip",LT_TYPE_STRING,tempRow[0],  
			   			"lbyte",LT_TYPE_STRING,flow
	   		    );
					}

        
	   			if(step==1){
	          	srvindex++;
	        }   			
        tempRow=ltDbFetchRow(tempCursor);
    }
    ltDbCloseCursor(tempCursor);

    if(step==1){											//画图
			  close(iFd);	 
			  sprintf(caLabel,"%s/Scripts/onlinesrv-bar.pl  %sdata.ini %ssrvreport.gif %llu ",_msahtmldir,caTempDir,caTempDir,lMaxBytes);  //柱状 饼图:onlinesrv1.pl
			  system(caLabel);	
			  lt_dbput_rootvars(dbPtr,1,"piechart","srvreport.gif" );
	  } 

	  
	  lt_dbput_rootvars(dbPtr,3,"reportname",reportname,"bdate",caSdate1,"edate",caSdate2);
	  sprintf(htmlpage,"%s%s/flow%d.htm",_msahtmldir,_flowlineplt,step);
	  printf("%s",htmlpage);
	  lt_page_content=ltPltFileParse(htmlpage,dbPtr->doc,0);
	  if(lt_page_content==NULL){
		    sprintf(caLabel,"/bin/echo '%s' > %serrmsg.ini","无报告数据,无法生成报告",caTempDir);
	  		system(caLabel);
	  		ltMsgFree(ltMsgPk);
	  		lt_dbfree(dbPtr);
     		return 0;
		}else{
			  lt_page_content=strstr(lt_page_content,"<!DOCTYPE");
			  if(step==1){
			  	sprintf(caLabel,"%sindex.htm",caTempDir);
			  }else{
			  	sprintf(caLabel,"%spage%d.htm",caTempDir,step);
			  }		  
			  iFd = open(caLabel,O_WRONLY | O_NDELAY | O_TRUNC | O_CREAT,0644); 
		    if(iFd >0) {
		          write(iFd,lt_page_content,strlen(lt_page_content));
		    }
	    	close(iFd);
	  }
   	
   	
    if(step==5){
	    sprintf(caLabel,"%s/Scripts/html2mail  %s index.htm %sindex.mht report %s",_msahtmldir,caTempDir,caTempDir,email);
	    system(caLabel);
    }

    
    chdir(caTempDir);
    system("rm -f report.tgz"); 
	  system("tar -cvzf report.tgz *");  	  
	  sprintf(caLabel,"/bin/rm  %sproccess.ini",caTempDir);
	  system(caLabel);    
	  sprintf(caLabel,"/bin/rm  %serrmsg.ini",caTempDir);
	  system(caLabel);   
	  ltMsgFree(ltMsgPk);
	  lt_dbfree(dbPtr);
    return 0;
}