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 msasAdminLogout(int confd,ltMsgHead *ltMsgPk,lt_shmHead *lt_MMHead){
	
	ltDbHeadPtr dbPtr;
	int i;
	
	char sIp[24];
	char strUserName[64];

	memset(sIp,0,sizeof(sIp));
	

	ltMsgGetSomeNVar(ltMsgPk,1,"clientip",    LT_TYPE_STRING, 19, sIp);
	
	dbPtr=lt_dbinit();
  lt_db_htmlpage(dbPtr,"utf-8");
  
  
  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 );
  		
  	}
  }
	

	
	
	 
	 {
				int lTime;
				char  caDate[64];
				char  sqlBuf[1024];
				lTime = time(0);
	    	strcpy(caDate,ltTimeFormat("%Y-%m-%d %H:%M:%S",lTime));
	    	sprintf(sqlBuf,"insert into msasadmlog values('%s','%s','user %s logout success. <from %s >','01')",strUserName,caDate,strUserName,sIp); 
				ltDbExecSql(G_DbCon,sqlBuf); 
   }
		    
   ltMsgPk->msgpktype=1;
   ltWebMsgErr("close!", confd,ltMsgPk);
	
	 ltMsgFree(ltMsgPk);
	 lt_dbfree(dbPtr);
	 return 0;

}
Ejemplo n.º 3
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);

}
Ejemplo n.º 4
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.º 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 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.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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;

}