Beispiel #1
0
//显示规则模板
int showServiceSimp(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
   ltDbHeadPtr dbPtr;
   ltTablePtr tablePtr;
	 dbPtr=lt_dbinit();
   lt_db_htmlpage(dbPtr,"utf-8");
		tablePtr=lt_dbput_table(dbPtr,"qoslist");
		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){
					lt_dbput_recordvars(tablePtr,2,
					  "jjrid",LT_TYPE_STRING,strid,
						"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){
					lt_dbput_recordvars(tablePtr,2,
					  "schid",LT_TYPE_STRING,strid,
						"schname",LT_TYPE_STRING,_ltPubInfo->_schtimelist[i].schname);
				}
		}
   ltMsgPk->msgpktype=1;
   lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msa/htmlplt/rule/serviceAddSimp.htm",dbPtr->head,0);
   ltMsgFree(ltMsgPk);
   lt_dbfree(dbPtr);
   return 0;
}
Beispiel #2
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;
}
Beispiel #3
0
int ltbandlink(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
	
	ltDbHeadPtr dbPtr;

	char    BANDUPLINK[24];
	char    BANDDOWNLINK[24];
	char    BANDUPDEF[24];
	char    BANDDOWNDEF[24];

	char    *pFile="/etc/msa/msa/qos/settings";
	

	
	dbPtr=lt_dbinit();
	lt_db_htmlpage(dbPtr,"utf-8");

  memset(BANDUPLINK,0,sizeof(BANDUPLINK));
	bcCnfGetValue_s(pFile,"BANDUPLINK",BANDUPLINK);
  lt_dbput_rootvars(dbPtr,1,"BANDUPLINK",BANDUPLINK );	
	
	
  memset(BANDDOWNLINK,0,sizeof(BANDDOWNLINK));
 	bcCnfGetValue_s(pFile,"BANDDOWNLINK",BANDDOWNLINK);
  lt_dbput_rootvars(dbPtr,1,"BANDDOWNLINK",BANDDOWNLINK );	
	
	if(ltStrIsDigital(BANDDOWNLINK)==0){
		_bcKernelHead->banddownlink=atol(BANDDOWNLINK);
	}
	if(ltStrIsDigital(BANDUPLINK)==0){
		_bcKernelHead->banduplink=atol(BANDUPLINK);
	}
	
	memset(BANDUPDEF,0,sizeof(BANDUPDEF));
	bcCnfGetValue_s(pFile,"BANDUPDEF",BANDUPDEF);
  lt_dbput_rootvars(dbPtr,1,"BANDUPDEF",BANDUPDEF );	
	
	
  memset(BANDDOWNDEF,0,sizeof(BANDDOWNDEF));
 	bcCnfGetValue_s(pFile,"BANDDOWNDEF",BANDDOWNDEF);
  lt_dbput_rootvars(dbPtr,1,"BANDDOWNDEF",BANDDOWNDEF );	
	
	if(ltStrIsDigital(BANDDOWNDEF)==0){
		_bcKernelHead->banddowndef=atol(BANDDOWNDEF)*1000;
	}
	if(ltStrIsDigital(BANDUPDEF)==0){
		_bcKernelHead->bandupdef=atol(BANDUPDEF)*1000;
	}
							
	
	lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msa/htmlplt/manager/bandlink.htm",dbPtr->head,0);

	ltMsgFree(ltMsgPk);
	lt_dbfree(dbPtr);
	return 0;

}
Beispiel #4
0
int msashowuserreportpage(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead)
{
     	ltDbHeadPtr dbPtr;
     	dbPtr=lt_dbinit();
	    lt_db_htmlpage(dbPtr,"utf-8");
	    lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msa/htmlplt/reportcenter/userline.htm",dbPtr->head,0);
			ltMsgFree(ltMsgPk);
			lt_dbfree(dbPtr);
			return 0;
}
Beispiel #5
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;
}
Beispiel #6
0
int ltjjrinfolist(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){	
 	 char sqlBuf[1024];
   ltDbHeadPtr dbPtr;
   ltTablePtr tablePtr;
   ltDbCursor *tempCursor;
   LT_DBROW tempRow;
   char mytime[400];
   
   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(mytime,0,sizeof(mytime));
//   if(checkRight(confd,ltMsgPk,21)==-1){//权限判断
//             return -1;
//   }
   dbPtr=lt_dbinit();
   lt_db_htmlpage(dbPtr,"utf-8");
   tablePtr=lt_dbput_table(dbPtr,"infolist");
   sprintf(sqlBuf,"select jjrid,jjrname,jjrdesc,jjrtime,jjrtime1 from nasjjr");
   tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
   if(tempCursor!=NULL){
             tempRow= ltDbFetchRow(tempCursor);
             while(tempRow!=NULL){
                      sprintf(mytime,"%s%s",tempRow[3],tempRow[4]);                
                      lt_dbput_recordvars(tablePtr,4,
                               "jjrid",LT_TYPE_STRING,tempRow[0],
                               "jjrname",LT_TYPE_STRING,tempRow[1],
                               "jjrdesc",LT_TYPE_STRING,tempRow[2],
                               "jjrtime",LT_TYPE_STRING,mytime);
                      tempRow= ltDbFetchRow(tempCursor);
             }
             ltDbCloseCursor(tempCursor);
   }
   lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msa/htmlplt/manager/jjredit.htm",dbPtr->head,0);
	 ltMsgFree(ltMsgPk);
	 lt_dbfree(dbPtr);
	 ltDbClose(G_DbCon);
	 return 0;
}
Beispiel #7
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;
}
Beispiel #8
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;
}
Beispiel #9
0
/*加载服务分类页面*/
int lturlsort(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
	 ltDbHeadPtr dbPtr;
	 dbPtr=lt_dbinit();
   lt_db_htmlpage(dbPtr,"utf-8");
  
   ltTablePtr  tablePtr;
   tablePtr=lt_dbput_table(dbPtr,"srvlist");	
   int iii,alltopsrvnum=0; 
   long lCount;
   char  myalltopsrvnum[16];
   char  mylCount[16];
   char  myallurl[100];
   long  allurl=10000000;
	 long  lTime = nasCvtLongTime("2011-10-01","00:00:00");
	 long  lTime1=time(0)-lTime;
   char  myallsrvrule[16];
	 char strBuf[1024];
	 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,"");
		 	 ltMsgFree(ltMsgPk);			
			 return 0;
	 }
   lCount=0; 
   sprintf(strBuf,"select count(*) from nassrv"); 
   tempCursor=ltDbOpenCursor(G_DbCon,strBuf);
   if(tempCursor!=NULL){
	  tempRow= ltDbFetchRow(tempCursor);
	  if(tempRow!=NULL){
		  lCount=atol(tempRow[0]);
	  }
   }
   ltDbCloseCursor(tempCursor);
   
	for(iii=0;iii<MAX_TOP_SRVNUM;iii++){
		if(strcmp(_ltPubInfo->topSrvName[iii].srvname,"")!=0){
 			alltopsrvnum++;
			lt_dbput_recordvars(tablePtr,2,"topsrvid",LT_TYPE_LONG,iii,"topsrvname",LT_TYPE_STRING,_ltPubInfo->topSrvName[iii].srvname);
		}
	} 
	sprintf(myalltopsrvnum,"%d",alltopsrvnum);//组
	lt_dbput_rootvars(dbPtr,1,"alltopsrvnum",myalltopsrvnum);
	
	sprintf(mylCount,"%ld",lCount);//总服务
	lt_dbput_rootvars(dbPtr,1,"allsrvnum",mylCount);
	
	sprintf(myallsrvrule,"%ld",lCount*2+27);//特征
	lt_dbput_rootvars(dbPtr,1,"allsrvrule",myallsrvrule);
	
	
	sprintf(myallurl,"%ld",allurl+(lTime1)/3600/24*100);
	lt_dbput_rootvars(dbPtr,1,"allurl",myallurl);
	lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msa/htmlplt/manager/nasurlsort.htm",dbPtr->head,0);        
	ltMsgFree(ltMsgPk); 
	lt_dbfree(dbPtr);
	return 0;
}
Beispiel #10
0
//报警参数配置
int msaalertLink(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
  		char mailalert[24],smsalert[24];
  		char diskalert[24],memalert[24],mail[64],telphone[64];
  		char newadminalert[24],newrulealert[24],delrulealert[24];
  		char outflowalert[24],p2pflowalert[24];
      char *pFile="/etc/msa/msa/alert";
    
     	ltDbHeadPtr dbPtr;
     	dbPtr=lt_dbinit();
	    lt_db_htmlpage(dbPtr,"utf-8");
	    
	    //报警方式
	    memset(mailalert,0,sizeof(mailalert));
		  bcCnfGetValue_s(pFile,"mailalert",mailalert); 
		  if(strcmp(mailalert,"yes")==0){
		   	lt_dbput_rootvars(dbPtr,1,"mailalert","checked"); 
		  }else{
		   	lt_dbput_rootvars(dbPtr,1,"mailalert","");
		  }
	    memset(mail,0,sizeof(mail));
		  bcCnfGetValue_s(pFile,"mail",mail);
		  lt_dbput_rootvars(dbPtr,1,"mail",mail);
	    memset(smsalert,0,sizeof(smsalert));
		  bcCnfGetValue_s(pFile,"smsalert",smsalert);
		  if(strcmp(smsalert,"yes")==0){
		   	lt_dbput_rootvars(dbPtr,1,"smsalert","checked"); 
		  }else{
		   	lt_dbput_rootvars(dbPtr,1,"smsalert","");
		  }
	    memset(telphone,0,sizeof(telphone));
		  bcCnfGetValue_s(pFile,"telphone",telphone);
		  lt_dbput_rootvars(dbPtr,1,"telphone",telphone);
	    //系统异常报警
	    memset(diskalert,0,sizeof(diskalert));
		  bcCnfGetValue_s(pFile,"diskalert",diskalert);
		  lt_dbput_rootvars(dbPtr,1,"diskalert",diskalert);
	    memset(memalert,0,sizeof(memalert));
		  bcCnfGetValue_s(pFile,"memalert",memalert);
		  lt_dbput_rootvars(dbPtr,1,"memalert",memalert); 
	    //关键操作报警
	    memset(newadminalert,0,sizeof(newadminalert));
		  bcCnfGetValue_s(pFile,"newadminalert",newadminalert);
		  if(strcmp(newadminalert,"yes")==0){
		   	lt_dbput_rootvars(dbPtr,1,"newadminalert","checked"); 
		  }else{
		   	lt_dbput_rootvars(dbPtr,1,"newadminalert","");
		  }
	    memset(newrulealert,0,sizeof(newrulealert));
		  bcCnfGetValue_s(pFile,"newrulealert",newrulealert);
		  if(strcmp(newrulealert,"yes")==0){
		   	lt_dbput_rootvars(dbPtr,1,"newrulealert","checked"); 
		  }else{
		   	lt_dbput_rootvars(dbPtr,1,"newrulealert","");
		  }
	    memset(delrulealert,0,sizeof(delrulealert));
		  bcCnfGetValue_s(pFile,"delrulealert",delrulealert);
		  if(strcmp(delrulealert,"yes")==0){
		   	lt_dbput_rootvars(dbPtr,1,"delrulealert","checked"); 
		  }else{
		   	lt_dbput_rootvars(dbPtr,1,"delrulealert","");
		  }
	    //网络异常报警
	    memset(outflowalert,0,sizeof(outflowalert));
		  bcCnfGetValue_s(pFile,"outflowalert",outflowalert);
		  lt_dbput_rootvars(dbPtr,1,"outflowalert",outflowalert);
	    memset(p2pflowalert,0,sizeof(p2pflowalert));
		  bcCnfGetValue_s(pFile,"p2pflowalert",p2pflowalert);
		  lt_dbput_rootvars(dbPtr,1,"p2pflowalert",p2pflowalert);  
	    
			
	    lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msa/htmlplt/rule/sysalertset.htm",dbPtr->head,0);
			ltMsgFree(ltMsgPk);
			lt_dbfree(dbPtr);
			return 0;
}
Beispiel #11
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;
}
Beispiel #12
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;
}
Beispiel #13
0
int msaShowTopview(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
	
		

  ltDbHeadPtr dbPtr; 

	char sRight[50];

	
	int  iIndex;
	char sIp[24];
	char langsel[12];
	int  i;

	memset(langsel,0,sizeof(langsel));

	sprintf(langsel,"%s","0");

		
  dbPtr=lt_dbinit();
	lt_db_htmlpage(dbPtr,"utf-8");
	
	memset(sIp,0,sizeof(sIp));
	ltMsgGetSomeNVar(ltMsgPk,2,"clientip",LT_TYPE_STRING, 19, sIp,"langsel",LT_TYPE_STRING, 12, langsel );
	
	if( strlen(langsel)<1 ){
	  	sprintf(langsel,"%s","0");
	}

	iIndex=-1;
  for(i=0;i<MAX_ADMIN_SESSION;i++){
  	
  	if(_ltPubInfo->admSession[i].lSip==ntohl(inet_addr(sIp)) ){
  		
  		   iIndex=i;
  		   break;
  	}
  }
  
  if(iIndex==-1 ){
  	ltWebMsgErr(_ltPubInfo->pubMsgStr[3].conStr, confd,ltMsgPk);
	  ltMsgFree(ltMsgPk);
		return 0;
	}

	
	
	if( (time(0)-_ltPubInfo->admSession[iIndex].lasttime) > 3600 ){
		ltWebMsgErr(_ltPubInfo->pubMsgStr[4].conStr, confd,ltMsgPk);
	  ltMsgFree(ltMsgPk);
		return 0;
	}
	
	_ltPubInfo->admSession[iIndex].lasttime=time(0);
	memset(sRight,0,sizeof(sRight));
	sprintf(sRight,"%s",_ltPubInfo->admSession[iIndex].lright);
    
  
//  if(sRight[0]=='1'){
//  	sprintf(caMsg,"%s","<td width=70 id=menu1 class=3dtable1_x  onClick=\"goto(this,'/adduser/adduser.htm');\" onmouseover=menuover(this)   onmouseout=menuout(this)>\r\n        ?????  \r\n</td>");
//  	lt_dbput_rootvars(dbPtr,1,"strhead1",caMsg);
//  }
//  

	 lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msas/htmlplt/main/top_header.htm",dbPtr->head,0);
		
		
	 ltMsgFree(ltMsgPk);
	 lt_dbfree(dbPtr);
	 return 0;

}
Beispiel #14
0
int msasShowAdminLogon(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
	
	
	ltDbHeadPtr dbPtr;
	
	unsigned int sid;
	char sIp[24];
  int  i;
	char strsid[12];

	int  adminipcount;
	int  ipok;
	
  char sqlBuf[1024];
	ltDbCursor *tempCursor;
	LT_DBROW tempRow;
	
	sid=0;
	memset(sIp,0,sizeof(sIp));


	ltMsgGetSomeNVar(ltMsgPk,1,"clientip",    LT_TYPE_STRING, 19, sIp);



	
	dbPtr=lt_dbinit();
  lt_db_htmlpage(dbPtr,"utf-8");
  

  adminipcount=0;
  ipok=0;
 

  
  sprintf(sqlBuf,"select count(*) from msasAdminArea ");
			
	tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
	if(tempCursor!=NULL){
				tempRow= ltDbFetchRow(tempCursor);
				if(tempRow!=NULL){
					adminipcount=atol(tempRow[0]);
				}
				ltDbCloseCursor(tempCursor);
	}
	

  if(adminipcount==0){
  	ipok=1;
  }else{
      unsigned int s_ip,e_ip,my_ip;
      my_ip=ntohl(inet_addr(sIp));
      
      sprintf(sqlBuf,"select ipstart,ipend from msasAdminArea ");
			
			tempCursor=ltDbOpenCursor(G_DbCon,sqlBuf);
			if(tempCursor!=NULL){
						tempRow= ltDbFetchRow(tempCursor);
						while(tempRow!=NULL){
							s_ip=ntohl(inet_addr(tempRow[0]));
							e_ip=ntohl(inet_addr(tempRow[1]));
							if( (my_ip >=s_ip) && (my_ip <=e_ip) ){ 
							   ipok=1;
							   break;
							}
						}
						ltDbCloseCursor(tempCursor);
			}
  }
	 

  if(ipok==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,"<html><body bgcolor=\"#cccccc\">Ip Area error!</body></html>");		
		 ltMsgFree(ltMsgPk);
		 return 0;
  	
  }
  
  for(i=0;i<MAX_ADMIN_SESSION;i++){
  	if(strcmp(_ltPubInfo->admSession[i].lright,"0000000000000000000000000000000000000000000")==0){
  		if( (time(0)-_ltPubInfo->admSession[i].lasttime) > MAX_ADMIN_TRYTIMEOUT  ){
          _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");		   
  	 }
  	}else{
  		if( (time(0)-_ltPubInfo->admSession[i].lasttime) > MAX_ADMIN_TIMEOUT  ){
          _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");		   
  		}
    }
  }
   
  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");		   
  	}
  }
	      
	{
	    
				gdImagePtr im;
				int   white,red;
				char caTempDir[128];
        char caTempFile[128];
        void *pJpg;
				int  lSize;
				
				
				sid=time(0)%10000;
				sprintf(strsid,"%04d",sid);
				
				im = gdImageCreate(40,16);
				red= gdImageColorAllocate(im, 0, 0, 0);
				white= gdImageColorAllocate(im, 255, 255, 255);
				
				gdImageRectangle(im, 0, 0, 40, 16, red);
				gdImageString(im, gdFontMediumBold, 5, 2, strsid, white);
				
				sprintf(caTempDir,"%s/%lu/",_TMPDIR,ltStrGetId());
		    if(ltFileIsExist(caTempDir)!=1) {
		        if(mkdir(caTempDir,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)!=0) {

		            return 0;
		        }
		    }
		    sprintf(caTempFile,"%scheck.jpg",caTempDir);
		    pJpg = gdImageJpegPtr( im,&lSize,-1);
		    gdImageDestroy(im);

		    saveJPG(pJpg,lSize, caTempFile);

		    lt_db_setcookie(dbPtr,"strsid", strsid);
		        
		    lt_dbput_rootvars(dbPtr,1,"file1",caTempFile+strlen(_TMPDIR)+1);
 
        ltMsgPk->msgpktype=1;
				lt_dbput_html(confd,ltMsgPk,dbPtr->doc,"/app/msa/msas/htmlplt/index.htm",dbPtr->head,0);
   }
	
 
	
	 ltMsgFree(ltMsgPk);
	 lt_dbfree(dbPtr);
	 return 0;

}
Beispiel #15
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;

}