예제 #1
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;
}
예제 #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;
}
예제 #3
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;
}
예제 #4
0
//LT_DBROW ltDbOneRow(ltDbConn *pConn,int *fieldnum,char *pSmt,...);
//void ltDbFreeRow(LT_DBROW dbRow,int fieldnum);
//ltDbCursor *ltDbOpenCursor(ltDbConn *pConn,  char *pSmt,...)
//void ltDbCloseCursor(ltDbCursor *ltCursor);
main(){
	ltDbConn *tempCon;
	LT_DBROW tempRow;
	int i,j;
	int fieldnum;
	ltDbCursor *tempCursor;
	tempCon=ltDbConnect("nc","nc",NULL);
	if(tempCon!=NULL){
		printf("ok\n");
	}else{
		printf("connect error\n");
	}
	tempCursor=ltDbOpenCursor(tempCon, "select * from NCADMUSER");
	if(tempCursor==NULL){
		printf("opn cursor eror\n");
	}
	/*fetch并得到字段值*/
	tempRow= ltDbFetchRow(tempCursor);
	fieldnum=ltNumField(tempCursor);
	printf("fieldnum:%d\n",fieldnum);
        j=0;
	while( tempRow!=NULL ){
		
		j++;
		printf("j:%d\n",j);
		for (i=0; i<fieldnum;i++){
			printf("%s\n",tempRow[i]);
		}
		if(j>10){
			break;
		}
		tempRow= ltDbFetchRow(tempCursor);
	}
	ltDbCloseCursor(tempCursor);	
	
	//int ltDbExecSql(ltDbConn *pConn,  char *pSmt,...);
	for(i=1;i<10000;i++){
		ltDbExecSql(tempCon,"insert into ncadmuser (name ,password) values ('xxxxxx%d','xxx')",i);
		//ltDbExecSql(tempCon,"delete ncadmuser where name ='xxx%d'",2900+i);
		ltDbCommit(tempCon);
	}
	
	ltDbClose(tempCon);

}
예제 #5
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;
}
예제 #6
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;
}
예제 #7
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;
}
예제 #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;
}
예제 #9
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;
}
예제 #10
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;
}
예제 #11
0
int on_proc_stop(lt_shmHead *lt_mmHead){
    
    ltDbClose(G_DbCon);
    //printf("db close ok\n");
    return 0;
}