Exemplo n.º 1
0
void get_session(int id)
{
	char* ptl[] = {
		"关闭",
		"TCP Client",
		"TCP Server",
		"UDP"
	};
	int i;
	char lsbuf[32]="";
	sprintf(lsbuf, "ptl%d", id);
	cgiFormSelectSingle(lsbuf, ptl, sizeof(ptl)/sizeof(ptl[0]), &i, 0);
	con_mode.session[id].protocol = i;

	bzero(lsbuf, 32);
	sprintf(lsbuf, "ip%d", id);
	char str[32]="";
	get_input(lsbuf, str);
	con_mode.session[id].ip = sys_str2ip(str);
	
	bzero(lsbuf, 32);
	sprintf(lsbuf, "lport%d", id);
	bzero(str, 32);
	get_input(lsbuf, str);
	con_mode.session[id].lport = atoi(str);

	bzero(lsbuf, 32);
	sprintf(lsbuf, "dport%d", id);
	bzero(str, 32);
	get_input(lsbuf, str);
	con_mode.session[id].dport = atoi(str);	

	
}
Exemplo n.º 2
0
void get_workmode(void)
{
	char* wmode[] = {
		"关闭",
		"TCP/UDP Socket"
	};
	int i;
	cgiFormSelectSingle("workmode", wmode, sizeof(wmode)/sizeof(wmode[0]), &i, 0);
	con_mode.mode = i;
}
Exemplo n.º 3
0
void get_datamode(void)
{
	char* dmode[] = {
		"raw",
		"telnet"	
	};
	int i;
	cgiFormSelectSingle("datamode", dmode, sizeof(dmode)/sizeof(dmode[0]), &i, 0);
	con_mode.tcp_mode= i;
}
Exemplo n.º 4
0
int ShowPolicerPage()
{
    int retz;
	ccgi_dbus_init();
	struct list *lpublic;	/*解析public.txt文件的链表头*/
	struct list *lcontrol; 	/*解析help.txt文件的链表头*/
	 lpublic=get_chain_head("../htdocs/text/public.txt");
   	 lcontrol=get_chain_head("../htdocs/text/control.txt"); 	
	  char *encry=(char *)malloc(BUF_LEN);
	  char *str;

	  char * mode=(char *)malloc(AMOUNT);
	  memset(mode,0,AMOUNT);
	 int result;
	  //char policer_encry[BUF_LEN];        
	  char addn[N];
	  int i=0;   
	  int cl=1;
	  int retu=0;
	  int policer_num=0;
	  char menu[21]="menulist";
	  char* i_char=(char *)malloc(10);
	  char * deletepolicer=(char * )malloc(10);
	  memset(deletepolicer,0,10);
	  char * index=(char * )malloc(10);
	  memset(index,0,10);
	  char * CheckUsr=(char * )malloc(10);
	  memset(CheckUsr,0,10);
	  char * disablecounter = (char *)malloc(10);
	  memset(disablecounter,0,10);
	  char * counterindex = (char *)malloc(10);
	  memset(counterindex,0,10);
	  struct policer_info receive_policer[Policer_Num];
	  //policer mode
	  char * policer_mode=(char * )malloc(10);
	  memset(policer_mode,0,10);
	  //policer mode information
	  char * policer_mode_info=(char * )malloc(10);
	  memset(policer_mode_info,0,10);
  
	  for(i=0;i<Policer_Num;i++)
		{
	    	receive_policer[i].policer_index=0;
	    	 receive_policer[i].policer_state=(char *)malloc(20);
	    	 memset(receive_policer[i].policer_state,0,20);
	    	 
	    	 receive_policer[i].CounterState=(char *)malloc(20);
	    	 memset(receive_policer[i].CounterState,0,20);
	    	 
	    	 receive_policer[i].Out_Profile_Action=(char *)malloc(20);
	    	 memset(receive_policer[i].Out_Profile_Action,0,20);
	    	 
	    	 receive_policer[i].Policer_Mode=(char *)malloc(20);
	    	 memset(receive_policer[i].Policer_Mode,0,20);
	    	 
	    	 receive_policer[i].Policing_Packet_Size=(char *)malloc(20);
	    	 memset(receive_policer[i].Policing_Packet_Size,0,20);

	    }
  
	  
		memset(encry,0,BUF_LEN);
	       cgiFormStringNoNewlines("UN", encry, BUF_LEN); 
	       str=dcryption(encry);
	       if(str==NULL)
	       {
		      ShowErrorPage(search(lpublic,"ill_user")); 	 /*用户非法*/
		      return 0;
		}
	  strcpy(addn,str);
	 
	  cgiFormStringNoNewlines("DELRULE",deletepolicer,10);
	  cgiFormStringNoNewlines("INDEX",index,10);
	  cgiFormStringNoNewlines("CheckUsr",CheckUsr,10);
	  cgiFormStringNoNewlines("ENABLE",disablecounter,10);
	  cgiFormStringNoNewlines("COUNTERINDEX",counterindex,10);
	  cgiFormStringNoNewlines("policer_mode",policer_mode,10);
	  cgiFormStringNoNewlines("policer_mode_info",policer_mode_info,10);

	  if(strcmp(CheckUsr,"")!=0)
	  	retu=atoi(CheckUsr);
	 
	show_qos_mode(mode);

	  cgiHeaderContentType("text/html");
	  fprintf(cgiOut,"<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>");
	  fprintf(cgiOut,"<meta http-equiv=Content-Type content=text/html; charset=gb2312>");
	  fprintf(cgiOut,"<title>%s</title>",search(lcontrol,"route_manage"));
	  fprintf(cgiOut,"<link rel=stylesheet href=/style.css type=text/css>"\
		  	"<style type=text/css>"\
	  	  "#div1{ width:42px; height:18px; border:1px solid #666666; background-color:#f9f8f7;}"\
		  "#div2{ width:50px; height:15px; padding-left:5px; padding-top:3px}"\
		  "#link{ text-decoration:none; font-size: 12px}"\
	  	".ShowPolicy {overflow-x:hidden;  overflow:auto; width: 750px; height: 386px; clip: rect( ); padding-top: 2px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px} "\
	  	"</style>"\
	  "</head>"\
	    "<script type=\"text/javascript\">"\
				  "function popMenu(objId)"\
				  "{"\
					 "var obj = document.getElementById(objId);"\
					 "if (obj.style.display == 'none')"\
					 "{"\
					   "obj.style.display = 'block';"\
					 "}"\
					 "else"\
					 "{"\
					   "obj.style.display = 'none';"\
					 "}"\
				 "}"\
		"</script>"\
	  "<body>");
	  if(strcmp(deletepolicer,"delete")==0)
	  {
	  	result=delete_policer(index);
		switch(result)
		{
			case 0:
				ShowAlert(search(lcontrol,"del_succ"));
				break;
			case -2:
				ShowAlert(search(lcontrol,"no_policer"));
				break;
			case -3:
				ShowAlert(search(lcontrol,"inuse_policer"));
				break;
			case -4:
				ShowAlert(search(lcontrol,"fail_del_policer"));
				break;
			default :
				ShowAlert(search(lpublic,"oper_fail"));
				break;
			}
	  }
	  if(cgiFormSubmitClicked("submit_policerlist") != cgiFormSuccess)
	  {
	  	retu=checkuser_group(str);
	  }
	  else if(cgiFormSubmitClicked("submit_policerlist") == cgiFormSuccess)
	  {
	  	 fprintf( cgiOut, "<script type='text/javascript'>\n" );
	 	 fprintf( cgiOut, "window.location.href='wp_qosModule.cgi?UN=%s';\n",encry);
	 	 fprintf( cgiOut, "</script>\n" );
	  }
	  
		if(strcmp(disablecounter,"disable")==0)
		{
			retz=counter_policer(counterindex,disablecounter,index);
			switch(retz)
			{
				case 0:
					ShowAlert(search(lpublic,"oper_succ"));
					break;
				default:
					ShowAlert(search(lpublic,"oper_fail"));
					break;
			}
		}

		if(cgiFormSubmitClicked("config_mode") == cgiFormSuccess)
		{	 
				
			if(strcmp(policer_mode,"strict")==0)
			{
			    	retz=set_strict_mode(policer_mode_info);
					switch(retz)
					{
						case 0:
							ShowAlert(search(lpublic,"oper_succ"));
							break;
						default:
							ShowAlert(search(lpublic,"oper_fail"));
							break;
					}
			}
			else if(strcmp(policer_mode,"loose")==0)
			{				
			    	retz=set_meter_loose_mode(policer_mode_info);
					switch(retz)
					{
						case 0:
							ShowAlert(search(lpublic,"oper_succ"));
							break;
						default:
							ShowAlert(search(lpublic,"oper_fail"));
							break;
					}
			}
		    	 fprintf(cgiOut, "<script type='text/javascript'>\n" );
		 	 fprintf(cgiOut, "window.location.href='wp_policer.cgi?UN=%s';\n",encry);
		 	 fprintf(cgiOut, "</script>\n" );
		}
		
  fprintf(cgiOut,"<form method=post>"\
  "<div align=center>"\
  "<table width=976 border=0 cellpadding=0 cellspacing=0>"\
  "<tr>"\
    "<td width=8 align=left valign=top background=/images/di22.jpg><img src=/images/youce4.jpg width=8 height=30/></td>"\
    "<td width=51 align=left valign=bottom background=/images/di22.jpg><img src=/images/youce33.jpg width=37 height=24/></td>"\
    "<td width=153 align=left valign=bottom background=/images/di22.jpg><font id=titleen>QOS</font><font id=%s> %s</font></td>",search(lpublic,"title_style"),search(lpublic,"management"));
    fprintf(cgiOut,"<td width=690 align=right valign=bottom background=/images/di22.jpg>");
    	  fprintf(cgiOut,"<table width=130 border=0 cellspacing=0 cellpadding=0>"\
          "<tr>"\
          "<td width=62 align=center><input id=but type=submit name=submit_policerlist style=background-image:url(/images/%s) value=""></td>",search(lpublic,"img_ok"));		  
          
		
     			fprintf(cgiOut,"<td width=62 align=left><a href=wp_qosModule.cgi?UN=%s target=mainFrame><img src=/images/%s border=0 width=62 height=20/></a></td>",encry,search(lpublic,"img_cancel"));

		  fprintf(cgiOut,"</tr>"\
          "</table>");
	fprintf(cgiOut,"</td>"\
    "<td width=74 align=right valign=top background=/images/di22.jpg><img src=/images/youce3.jpg width=31 height=30/></td>"\
  "</tr>"\
  "<tr>"\
    "<td colspan=5 align=center valign=middle><table width=976 border=0 cellpadding=0 cellspacing=0 bgcolor=#f0eff0>"\
      "<tr>"\
        "<td width=12 align=left valign=top background=/images/di888.jpg>&nbsp;</td>"\
        "<td width=948><table width=947 border=0 cellspacing=0 cellpadding=0>"\
            "<tr height=4 valign=bottom>"\
              "<td width=120>&nbsp;</td>"\
              "<td width=827 valign=bottom><img src=/images/bottom_05.gif width=827 height=4/></td>"\
            "</tr>"\
            "<tr>"\
              "<td><table width=120 border=0 cellspacing=0 cellpadding=0>"\
                   "<tr height=25>"\
                    "<td id=tdleft>&nbsp;</td>"\
                  "</tr>");       
	#if 0
         		if(cgiFormSubmitClicked("submit_policerlist") != cgiFormSuccess)
         		{
         			fprintf(cgiOut,"<tr height=26>"\
         			"<td align=left id=tdleft background=/images/bottom_bg.gif style=\"border-right:0\"><font id=%s>%s</font></td>",search(lpublic,"menu_san"),search(lcontrol,"policer"));   /*突出显示*/
         			fprintf(cgiOut,"</tr>");
         			if(retu==0)
         			{
            			fprintf(cgiOut,"<tr height=25>"\
            			"<td align=left id=tdleft><a href=wp_addpolicer.cgi?UN=%s target=mainFrame class=top><font id=%s>%s</font></a></td>",encry,search(lpublic,"menu_san"),search(lcontrol,"add_policer"));					   
            			fprintf(cgiOut,"</tr>");
         			}
				fprintf(cgiOut,"<tr height=26>"\
             			"<td align=left id=tdleft><a href=wp_qoscounter.cgi?UN=%s target=mainFrame class=top><font id=%s>%s</font></a></td>",encry,search(lpublic,"menu_san"),search(lcontrol,"counter"));					   
             			fprintf(cgiOut,"</tr>");

         		}
         		else if(cgiFormSubmitClicked("submit_policerlist") == cgiFormSuccess) 			  
         		{
         		#endif
         			fprintf(cgiOut,"<tr height=26>"\
         			"<td align=left id=tdleft background=/images/bottom_bg.gif style=\"border-right:0\"><font id=%s>%s</font></td>",search(lpublic,"menu_san"),search(lcontrol,"policer"));   /*突出显示*/
         			fprintf(cgiOut,"</tr>");
         			if(retu==0)
         			{
	             			fprintf(cgiOut,"<tr height=25>"\
	             			"<td align=left id=tdleft><a href=wp_addpolicer.cgi?UN=%s target=mainFrame class=top><font id=%s>%s</font></a></td>",encry,search(lpublic,"menu_san"),search(lcontrol,"add_policer"));					   
	             			fprintf(cgiOut,"</tr>");
         			}
				fprintf(cgiOut,"<tr height=26>"\
             			"<td align=left id=tdleft><a href=wp_qoscounter.cgi?UN=%s target=mainFrame class=top><font id=%s>%s</font></a></td>",encry,search(lpublic,"menu_san"),search(lcontrol,"counter"));					   
             			fprintf(cgiOut,"</tr>");
				
         		//}
         		int rowsCount=0;
         		if(retu==0)
         			rowsCount=15;
         		else
         			rowsCount=16;
				for(i=0;i<rowsCount;i++)
					{
						fprintf(cgiOut,"<tr height=25>"\
						  "<td id=tdleft>&nbsp;</td>"\
						"</tr>");
					}
				  fprintf(cgiOut,"</table>"\
              "</td>"\
              "<td align=left valign=top style=\"background-color:#ffffff; border-right:1px solid #707070; padding-left:30px; padding-top:10px\">"\
						"<table width=700 height=310 border=0 cellspacing=0 cellpadding=0>");
				 
			fprintf(cgiOut,"<tr>"\
							"<td id=sec1 style=\"border-bottom:2px solid #53868b;font-size:14px\">\n"\
								"<table width=%s>\n","90%");
									fprintf(cgiOut,"<tr>\n"\
										"<td id=sec1 style=\"font-size:14px\">%s</td>",search(lcontrol,"policy_map_info"));
							fprintf(cgiOut,"<td id=sec1 style=\"font-size:14px\" align='right'><font color='red'><b>%s</b></font></td>",search(lcontrol,mode));
						fprintf(cgiOut,"</tr>\n"\
								"</table>\n"\
							"</td>\n");
			fprintf(cgiOut,"</tr>");
						 //////////////////new/////////////////////
				if(checkuser_group(addn)==0)/*administrator*/
				{
				  fprintf(cgiOut,"<tr><td>&nbsp;</td></tr>");
				  fprintf(cgiOut,"<tr>");
				  	fprintf(cgiOut,"<td>");
				  		fprintf(cgiOut,"<table>");
				  
				  		fprintf(cgiOut,"<tr align=left  style=padding-top:8px>");
						    fprintf(cgiOut,"<td id=td1 width=110>%s:</td>",search(lcontrol,"config_policer_mode"));
						    fprintf(cgiOut,"<td  align=left style=padding-left:10px width=50><select name=policer_mode onchange=\"javascript:this.form.submit();\">");
						    for(i=0;i<2;i++)
							if(strcmp(Policer_Mode[i],policer_mode)==0)				/*显示上次选中的*/
								fprintf(cgiOut,"<option value=%s selected=selected>%s",Policer_Mode[i],Policer_Mode[i]);
							else				
								fprintf(cgiOut,"<option value=%s>%s",Policer_Mode[i],Policer_Mode[i]);
						    fprintf(cgiOut,"</select>\n");
						    fprintf(cgiOut,"</td>");
						    int policer_modechoice=0;
							cgiFormSelectSingle("policer_mode", Policer_Mode, 2, &policer_modechoice, 0);
			                            if(policer_modechoice==0)
			                            {
			                         
								fprintf(cgiOut,"<td  align=left style=padding-left:10px><select name=policer_mode_info>");
				  
				    				fprintf(cgiOut,"<option value=%s>%s","l1","L1");
				    				fprintf(cgiOut,"<option value=%s>%s","l2","L2");
				    				fprintf(cgiOut,"<option value=%s>%s","l3","L3");
				    				fprintf(cgiOut,"</select>");
				    				fprintf(cgiOut,"</td>");
							}
							else if(policer_modechoice==1)
							{
								fprintf(cgiOut,"<td  align=left style=padding-left:10px><select name=policer_mode_info>");

			    					fprintf(cgiOut,"<option value=%s>%s","0","0");
			    					fprintf(cgiOut,"<option value=%s>%s","1","1");
			    					fprintf(cgiOut,"<option value=%s>%s","2","2");
			    					fprintf(cgiOut,"</select>");
			    					fprintf(cgiOut,"</td>");
							}

							fprintf(cgiOut,"<td align=left style=padding-left:10px>");
								fprintf(cgiOut,"<input type=submit style=width:70px; height:36px  border=0 name=config_mode style=background-image:url(/images/SubBackGif.gif) value=\"%s\">",search(lcontrol,"mode_submit"));
							fprintf(cgiOut,"</td>");
						fprintf(cgiOut,"</tr>");
								fprintf(cgiOut,"</table>");
							fprintf(cgiOut,"</td>");
						fprintf(cgiOut,"</tr>");
					}
				  ///////////////////////////////////////
			fprintf(cgiOut,"<tr>"\
						   "<td align=left valign=top style=padding-top:18px>"\
						   "<div class=ShowPolicy><table width=688 border=1 frame=below rules=rows bordercolor=#cccccc cellspacing=0 cellpadding=0>");
						   fprintf(cgiOut,"<tr height=30 bgcolor=#eaeff9 style=font-size:14px  id=td1 align=left>"\
							 "<th width=45 style=font-size:12px><font id=%s>%s</font></th>", search(lpublic,"menu_thead"),"Index");
							 fprintf(cgiOut,"<th width=45 style=font-size:12px><font id=%s>%s</font></th>", search(lpublic,"menu_thead"),search(lcontrol,"Policer_State"));
							 fprintf(cgiOut,"<th width=40 style=font-size:12px><font id=%s>%s</font></th>", search(lpublic,"menu_thead"),"CIR");
							 fprintf(cgiOut,"<th width=40 style=font-size:12px><font id=%s>%s</font></th>", search(lpublic,"menu_thead"),"CBS");
							 fprintf(cgiOut,"<th width=110 style=font-size:12px><font id=%s>%s</font></th>", search(lpublic,"menu_thead"),"Counter State");
							 fprintf(cgiOut,"<th width=110 style=font-size:12px><font id=%s>%s</font></th>", search(lpublic,"menu_thead"),"Counter Index");
							 fprintf(cgiOut,"<th width=85 style=font-size:12px><font id=%s>%s</font></th>", search(lpublic,"menu_thead"),search(lcontrol,"Out_Profile"));
							 fprintf(cgiOut,"<th width=100 style=font-size:12px><font id=%s>%s</font></th>", search(lpublic,"menu_thead"),search(lcontrol,"Remap_QOS"));
							 fprintf(cgiOut,"<th width=50 style=font-size:12px><font id=%s>%s</font></th>", search(lpublic,"menu_thead"),search(lcontrol,"Policer_Mode"));
							 fprintf(cgiOut,"<th width=50 style=font-size:12px><font id=%s>%s</font></th>", search(lpublic,"menu_thead"),search(lcontrol,"Policer_Size"));
							 fprintf(cgiOut,"<th width=13 style=font-size:12px>&nbsp;</th>");
							 fprintf(cgiOut,"</tr>");
							show_policer(receive_policer,&policer_num);
							
							for(i=0;i<policer_num;i++)
							{
								memset(menu,0,21);
							  	strcpy(menu,"menulist");
							  	sprintf(i_char,"%d",i+1);
							  	strcat(menu,i_char);

								fprintf(cgiOut,"<tr height=25 bgcolor=%s align=left>",setclour(cl));
								 fprintf(cgiOut,"<td style=font-size:12px>%u</td>",receive_policer[i].policer_index);
								 fprintf(cgiOut,"<td style=font-size:12px>%s</td>",receive_policer[i].policer_state);
								 fprintf(cgiOut,"<td style=font-size:12px>%ld</td>",receive_policer[i].cir);
								 fprintf(cgiOut,"<td style=font-size:12px>%ld</td>",receive_policer[i].cbs);
								 fprintf(cgiOut,"<td style=font-size:12px align='center'>%s</td>",receive_policer[i].CounterState);
								 if(receive_policer[i].CounterIndex==0)
								 {
								 	fprintf(cgiOut,"<td style=font-size:12px align='center'>%s</td>","No");
								 }
								 else
								 {
								 	fprintf(cgiOut,"<td style=font-size:12px align='center'>%d</td>",receive_policer[i].CounterIndex);
								 }
								 fprintf(cgiOut,"<td style=font-size:12px align='center'>%s</td>",receive_policer[i].Out_Profile_Action);
								 fprintf(cgiOut,"<td style=font-size:12px align='center'>%u</td>",receive_policer[i].Remap_QoSProfile);
								 fprintf(cgiOut,"<td style=font-size:12px>%s</td>",receive_policer[i].Policer_Mode);
								 fprintf(cgiOut,"<td style=font-size:12px>%s</td>",receive_policer[i].Policing_Packet_Size);
								 if(retu==0)
								 {
    								 fprintf(cgiOut,"<td align=left>");
    								 fprintf(cgiOut,"<div style=\"position:relative; z-index:%d\" onmouseover=\"popMenu('%s');\" onmouseout=\"popMenu('%s');\">",(policer_num-i),menu,menu);
    																   fprintf(cgiOut,"<img src=/images/detail.gif>"\
    																   "<div id=%s style=\"display:none; position:absolute; top:5px; left:0;\">",menu);
    																   fprintf(cgiOut,"<div id=div1>");
																	   
    																  //if(cgiFormSubmitClicked("submit_policerlist") != cgiFormSuccess)
    																  // {
    																   		fprintf(cgiOut,"<div id=div2 onmouseover=\"this.style.backgroundColor='#b6bdd2'\" onmouseout=\"this.style.backgroundColor='#f9f8f7'\"><a id=link href=wp_conpolicer.cgi?UN=%s&INDEX=%u&COUNTERINDEX=%d target=mainFrame>%s</a></div>",encry,receive_policer[i].policer_index,receive_policer[i].CounterIndex,search(lpublic,"configure"));
        																   	fprintf(cgiOut,"<div id=div2 onmouseover=\"this.style.backgroundColor='#b6bdd2'\" onmouseout=\"this.style.backgroundColor='#f9f8f7'\"><a id=link href=wp_policer.cgi?UN=%s&INDEX=%u&DELRULE=%s target=mainFrame onclick=\"return confirm('%s')\">%s</a></div>",encry,receive_policer[i].policer_index,"delete",search(lcontrol,"confirm_delete"),search(lcontrol,"delete"));
        																   	if(receive_policer[i].CounterIndex!=0)
        																   	{
        																   		fprintf(cgiOut,"<div id=div2 onmouseover=\"this.style.backgroundColor='#b6bdd2'\" onmouseout=\"this.style.backgroundColor='#f9f8f7'\"><a id=link href=wp_policer.cgi?UN=%s&INDEX=%u&COUNTERINDEX=%d&ENABLE=%s target=mainFrame>%s</a></div>",encry,receive_policer[i].policer_index,receive_policer[i].CounterIndex,"disable",search(lcontrol,"counter_disable"));
        																   	}
																		#if 0	
    																   	}
    																   else
    																   {
    																  
																	   
    																		fprintf(cgiOut,"<div id=div2 onmouseover=\"this.style.backgroundColor='#b6bdd2'\" onmouseout=\"this.style.backgroundColor='#f9f8f7'\"><a id=link href=wp_conpolicer.cgi?UN=%s&INDEX=%u&COUNTERINDEX=%d target=mainFrame>%s</a></div>",encry,receive_policer[i].policer_index,receive_policer[i].CounterIndex,search(lpublic,"configure"));
        																   	fprintf(cgiOut,"<div id=div2 onmouseover=\"this.style.backgroundColor='#b6bdd2'\" onmouseout=\"this.style.backgroundColor='#f9f8f7'\"><a id=link href=wp_policer.cgi?UN=%s&INDEX=%u&DELRULE=%s target=mainFrame >%s</a></div>",encry,receive_policer[i].policer_index,"delete",search(lcontrol,"confirm_delete"),search(lcontrol,"delete"));
        																   	if(receive_policer[i].CounterIndex!=0)
        																   	{
        																   		fprintf(cgiOut,"<div id=div2 onmouseover=\"this.style.backgroundColor='#b6bdd2'\" onmouseout=\"this.style.backgroundColor='#f9f8f7'\"><a id=link href=wp_policer.cgi?UN=%s&INDEX=%u&COUNTERINDEX=%d&ENABLE=%s target=mainFrame>%s</a></div>",encry,receive_policer[i].policer_index,receive_policer[i].CounterIndex,"disable",search(lcontrol,"counter_disable"));
        																   	}
    																	//}
    																	 #endif
    																   fprintf(cgiOut,"</div>"\
    																   "</div>"\
    																   "</div>");
    																   fprintf(cgiOut,"</td>");
								}
								 else  fprintf(cgiOut,"<td>&nbsp;</td>");
							 fprintf(cgiOut,"</tr>");
								 cl=!cl;
							}
Exemplo n.º 5
0
void Color() {
	int colorChoice;
	cgiFormSelectSingle("colors", colors, 3, &colorChoice, 0);
	fprintf(cgiOut, "I am: %s<BR>\n", colors[colorChoice]);
}	 
Exemplo n.º 6
0
void ShowPrtFunCfgPage(char *m,char *n,char *t,char *s,struct list *lpublic,struct list *lcon)
{ 
  char *slot_port=(char *)malloc(10);
  int i,modeChoice,num,ret;
  char * url_temp =(char *)malloc(1024);
  memset(url_temp,0,1024);
  struct eth_port_s pr;
  struct slot sr;
  ETH_SLOT_LIST  head,*p;
  ETH_PORT_LIST *pp;
  pr.attr_bitmap=0;
  pr.mtu=0;
  pr.port_type=0;
  sr.module_status=0;     
  sr.modname=(char *)malloc(20);     //为结构体成员申请空间,假设该字段的最大长度为20
  sr.sn=(char *)malloc(20);          //为结构体成员申请空间,假设该字段的最大长度为20
  sr.hw_ver=0;
  sr.ext_slot_num=0;  
  cgiHeaderContentType("text/html");
  fprintf(cgiOut,"<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>");
  fprintf(cgiOut,"<meta http-equiv=Content-Type content=text/html; charset=gb2312>");
  fprintf(cgiOut,"<title>%s</title>",search(lcon,"prt_manage"));
  fprintf(cgiOut,"<link rel=stylesheet href=/style.css type=text/css>"\
  	"<style type=text/css>"\
  	".a3{width:30;border:0; text-align:center}"\
  	"</style>"\
  "</head>"\
  "<script src=/ip.js>"\
  "</script>"\
  "<body>");

  
  if(cgiFormSubmitClicked("PrtFunCfg_apply") == cgiFormSuccess)
  {
    PortFunConfig(s,t,lpublic,lcon);
  }
  fprintf(cgiOut,"<form>"\
  "<div align=center>"\
  "<table width=976 border=0 cellpadding=0 cellspacing=0>"\
  "<tr>"\
      "<td width=8 align=left valign=top background=/images/di22.jpg><img src=/images/youce4.jpg width=8 height=30/></td>"\
    "<td width=51 align=left valign=bottom background=/images/di22.jpg><img src=/images/youce33.jpg width=37 height=24/></td>"\
    "<td width=153 align=left valign=bottom id=%s background=/images/di22.jpg>%s</td>",search(lpublic,"title_style"),search(lcon,"prt_manage"));
    fprintf(cgiOut,"<td width=692 align=right valign=bottom background=/images/di22.jpg>");
		{	
		  fprintf(cgiOut,"<table width=130 border=0 cellspacing=0 cellpadding=0>"\
		  "<tr>"\
		  "<td width=62 align=center><input id=but type=submit name=PrtFunCfg_apply style=background-image:url(/images/%s) value=""></td>"\
		  "<td width=62 align=left><a href=wp_contrl.cgi?UN=%s target=mainFrame><img src=/images/%s border=0 width=62 height=20/></a></td>",search(lpublic,"img_ok"),m,search(lpublic,"img_cancel"));
		  fprintf(cgiOut,"</tr>"\
		  "</table>");
		}
	fprintf(cgiOut,"</td>"\
    "<td width=74 align=right valign=top background=/images/di22.jpg><img src=/images/youce3.jpg width=31 height=30/></td>"\
  "</tr>"\
  "<tr>"\
    "<td colspan=5 align=center valign=middle><table width=976 border=0 cellpadding=0 cellspacing=0 bgcolor=#f0eff0>"\
      "<tr>"\
        "<td width=12 align=left valign=top background=/images/di888.jpg>&nbsp;</td>"\
        "<td width=948><table width=947 border=0 cellspacing=0 cellpadding=0>"\
            "<tr height=4 valign=bottom>"\
              "<td width=120>&nbsp;</td>"\
              "<td width=827 valign=bottom><img src=/images/bottom_05.gif width=827 height=4/></td>"\
            "</tr>"\
            "<tr>"\
              "<td><table width=120 border=0 cellspacing=0 cellpadding=0>"\
                   "<tr height=25>"\
                    "<td id=tdleft>&nbsp;</td>"\
                  "</tr>");					    
					fprintf(cgiOut,"<tr height=25>"\
					  "<td align=left id=tdleft><a href=wp_prtsur.cgi?UN=%s target=mainFrame class=top><font id=%s>%s<font></a></td>",m,search(lpublic,"menu_san"),search(lcon,"prt_sur"));						
					fprintf(cgiOut,"</tr>"		
					"<tr height=25>"\
  					    "<td align=left id=tdleft><a href=wp_prtarp.cgi?UN=%s target=mainFrame class=top><font id=yingwen_san>ARP<font><font id=%s> %s<font></a></td></tr>",m,search(lpublic,"menu_san"),search(lpublic,"survey"));                       
					fprintf(cgiOut,"<tr height=25>"\
					  "<td align=left id=tdleft><a href=wp_static_arp.cgi?UN=%s target=mainFrame class=top><font id=%s>%s<font></a></td></tr>",m,search(lpublic,"menu_san"),search(lcon,"prt_static_arp"));						 
					
                    fprintf(cgiOut,"<tr height=25>"\
  					  "<td align=left id=tdleft><a href=wp_prtcfg.cgi?UN=%s target=mainFrame class=top><font id=%s>%s<font></a></td>",m,search(lpublic,"menu_san"),search(lcon,"prt_cfg"));                       
                    fprintf(cgiOut,"</tr>"\
                    "<tr height=26>"\
                      "<td align=left id=tdleft background=/images/bottom_bg.gif style=\"border-right:0\"><font id=%s>%s<font></td>",search(lpublic,"menu_san"),search(lcon,"func_cfg"));     /*突出显示*/
                    fprintf(cgiOut,"</tr>");
					//add by sjw  2008-10-9 17:14:37  for  subinterface
					fprintf(cgiOut,"<tr height=25>"\
  					    "<td align=left id=tdleft><a href=wp_subintf.cgi?UN=%s target=mainFrame class=top><font id=%s>%s<font></a></td></tr>",m,search(lpublic,"menu_san"),search(lcon,"title_subintf"));  	                    
										fprintf(cgiOut,"<tr height=25>"\
						  "<td align=left id=tdleft><a href=wp_interface_bindip.cgi?UN=%s target=mainFrame class=top><font id=%s>%s<font></a></td></tr>",m,search(lpublic,"menu_san"),search(lpublic,"config_interface"));
					//////INTF ////////
					fprintf(cgiOut,"<tr height=25>"\
  					    "<td align=left id=tdleft><a href=wp_all_interface.cgi?UN=%s target=mainFrame class=top><font id=%s>%s<font></a></td></tr>",m,search(lpublic,"menu_san"),search(lcon,"interface"));		

                fprintf(cgiOut,"</table>"\
              "</td>"\
              "<td align=left style=\"background-color:#ffffff; border-right:1px solid #707070; padding-left:30px\">"\
				"<table width=390 border=0 cellspacing=0 cellpadding=0>"\
				   "<tr height=30>"\
					  "<td width=100px>%s:</td>",search(lcon,"port_no"));
					  fprintf(cgiOut,"<td colspan=3><select name=port_num style=width:50px>");  
					  ccgi_dbus_init();
					  ret=show_ethport_list(&head,&num);
					  p=head.next;
					  if(p!=NULL)
					  {
						  while(p!=NULL)
						  {
							  pp=p->port.next;
							  while(pp!=NULL)
							  {
								  memset(slot_port,0,10);							
							      sprintf(slot_port,"%d-%d",p->slot_no,pp->port_no);
							      if(strcmp(slot_port,s)==0)
								    fprintf(cgiOut,"<option value=%s selected=selected>%s",slot_port,slot_port);
							      else
							        fprintf(cgiOut,"<option value=%s>%s",slot_port,slot_port);
								  pp=pp->next;
							  }
							  p=p->next;
						  }
					  }
			          fprintf(cgiOut,"</select></td>");  //端口号的下拉框显示		
			          
					  /*---------------------------------------------------------------*/
					  
					fprintf(cgiOut,"</tr>"\
					"<tr height=30>"\
					  "<td >%s:</td>",search(lpublic,"mode"));
					  fprintf(cgiOut,"<td width=140 colspan=2><select name=port_mode style=width:95px onchange=\"javascript:this.form.submit();\">");
					    for(i=0;i<3;i++)
			            if(strcmp(port_mode[i],t)==0)              /*显示上次选中的port mode*/
       	                  fprintf(cgiOut,"<option value=%s selected=selected>%s",port_mode[i],port_mode[i]);
			            else			  	
			              fprintf(cgiOut,"<option value=%s>%s",port_mode[i],port_mode[i]);
					  fprintf(cgiOut,"</select></td>");
			        fprintf(cgiOut,"<td width=200><font color=red>%s</font></td>", search( lcon,"prt_mod_default"));
					fprintf(cgiOut,"</tr>");
					cgiFormSelectSingle("port_mode", port_mode, 3, &modeChoice, 0);
					#if 0
					if(modeChoice!=0)
					{
					  fprintf(cgiOut,"<tr height=30>"\
					    "<td>IP:</td>"\
					    "<td>" );
					      fprintf( cgiOut, "<div style=\"border-width:1;border-color:#a5acb2;border-style:solid;width:140;font-size:9pt\">" );
              	          fprintf( cgiOut, "<input type=text name='port_ip1' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>.",search(lpublic,"ip_error"));
              	          fprintf(cgiOut,"<input type=text name='port_ip2' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>.",search(lpublic,"ip_error"));
              	          fprintf(cgiOut,"<input type=text name='port_ip3' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>.",search(lpublic,"ip_error"));
              	          fprintf(cgiOut,"<input type=text name='port_ip4' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>",search(lpublic,"ip_error"));
              	          fprintf(cgiOut,"</div>"\
					    "</td>"\
					    "<td>/</td>" );
					      fprintf( cgiOut, "<td><div style=\"border-width:1;border-color:#a5acb2;border-style:solid;width:140;font-size:9pt\">" );
              	          fprintf( cgiOut, "<input type=text name='port_mask1' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>.",search(lpublic,"ip_error"));
              	          fprintf(cgiOut,"<input type=text name='port_mask2' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>.",search(lpublic,"ip_error"));
              	          fprintf(cgiOut,"<input type=text name='port_mask3' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>.",search(lpublic,"ip_error"));
              	          fprintf(cgiOut,"<input type=text name='port_mask4' maxlength=3 class=a3 onKeyUp=\"mask(this,%s)\" onbeforepaste=mask_c()>",search(lpublic,"ip_error"));
					    fprintf( cgiOut, "</div></td>"\
					  "</tr>");
					}
					#endif
					if(modeChoice==1)
					{
						sprintf( url_temp, "wp_interface_bindip.cgi?UN=%s&PORT=%s&MODE=%s",m,s,"route");
						fprintf( cgiOut, "<script type='text/javascript'>\n" );
						fprintf( cgiOut, "window.location.href='%s';\n", url_temp );
						fprintf( cgiOut, "</script>\n" );
					}
					else if(modeChoice==2)
					{
						sprintf( url_temp, "wp_interface_bindip.cgi?UN=%s&PORT=%s&MODE=%s",m,s,"promiscuous");
						fprintf( cgiOut, "<script type='text/javascript'>\n" );
						fprintf( cgiOut, "window.location.href='%s';\n", url_temp );
						fprintf( cgiOut, "</script>\n" );
					}
					fprintf(cgiOut,"<tr>"\
                      "<td colspan=4><input type=hidden name=encry_PrtFunCfg value=%s></td>",m);
                    fprintf(cgiOut,"</tr>"\
				  "</table>"\
              "</td>"\
            "</tr>"\
            "<tr height=4 valign=top>"\
              "<td width=120 height=4 align=right valign=top><img src=/images/bottom_07.gif width=1 height=10/></td>"\
              "<td width=827 height=4 valign=top bgcolor=#FFFFFF><img src=/images/bottom_06.gif width=827 height=15/></td>"\
            "</tr>"\
          "</table>"\
        "</td>"\
        "<td width=15 background=/images/di999.jpg>&nbsp;</td>"\
      "</tr>"\
    "</table></td>"\
  "</tr>"\
  "<tr>"\
    "<td colspan=3 align=left valign=top background=/images/di777.jpg><img src=/images/di555.jpg width=61 height=62/></td>"\
    "<td align=left valign=top background=/images/di777.jpg>&nbsp;</td>"\
    "<td align=left valign=top background=/images/di777.jpg><img src=/images/di666.jpg width=74 height=62/></td>"\
  "</tr>"\
"</table>"\
"</div>"\
"</form>"\
"</body>"\
"</html>"); 
free(slot_port);
free(sr.modname);
free(sr.sn); 
free(url_temp);
if((ret==0)&&(num>0))
{
	Free_ethslot_head(&head);
}
}        
Exemplo n.º 7
0
static int s_usr_mng_prefix_of_page( STPageInfo *pstPageInfo )
{

	FILE *fp = pstPageInfo->fp;
	fprintf(fp, "<style type=text/css>"\
  				"#div1{ width:62px; height:18px; border:1px solid #666666; background-color:#f9f8f7;}"\
    			"#div2{ width:60px; height:15px; padding-left:5px; padding-top:3px}"\
   				"#link{ text-decoration:none; font-size: 12px}"\
   				"</style>");
	fprintf(fp,	"<script type=\"text/javascript\">"\
				"function popMenu(objId)"\
				"{"\
			   		"var obj = document.getElementById(objId);"\
			   		"if (obj.style.display == 'none')"\
			   		"{"\
				 		"obj.style.display = 'block';"\
			   		"}"\
			   		"else"\
			   		"{"\
				 		"obj.style.display = 'none';"\
			   		"}"\
		  	 	"}"\
		   		"</script>");
	struct list * portal_lcon 		= pstPageInfo->pstPortalContainer->lcon;
	struct list * portal_lauth = pstPageInfo->lauth;
		
	char all_data_num[10];
	memset( all_data_num, 0, 10 );
	
	char downflag[20];
	memset( downflag, 0, 20 );
	char c_userip[20];
	memset( c_userip, 0, 20 );
	int i_userip = 0;
	char *endptr;

	//memset( &search_user, 0, sizeof(STOnlineUserInfo) );
	//memset(total_num,0,10);
	
	////////全局初始化////////////
	memset(PNtemp,0,10);
	FirstPage = 1;//首页为第一页
	LastPage = 0;
	pageNum = 1; //初始进第一页
	totalNum = 0;
	search_switch = 0;
	search_point = 0;
	
	cgiFormStringNoNewlines( "TOTAL", all_data_num, 10 );
	//fprintf( stderr, "all_data_num=%s\n" ,all_data_num );
	if( strcmp(all_data_num,"") != 0)
	{
    	totalNum=atoi(all_data_num);
	}
	
    cgiFormStringNoNewlines( "PN", PNtemp, 10 );
	if( strcmp(PNtemp,"") != 0)
	{
    	pageNum=atoi(PNtemp);
	}
	
	//fprintf( stderr, "pageNum=%d--totalNumPage=%d\n" ,pageNum, totalNum );
	//////////强制下线///////////////////////
	cgiFormStringNoNewlines( "DOWNRULE", downflag, 20 );
	if( !strcmp(downflag, "USERDOWN") )
	{
		cgiFormStringNoNewlines( "USERIP", c_userip, 20 );
		i_userip = strtoul(c_userip, &endptr, 0);
		fprintf( stderr, "i_userip=%d", i_userip );

		pstPageInfo->pstReq = createRequirePkg( REQ_LOGOUT_BY_INFO, &i_userip, NULL );
		if( NULL == pstPageInfo->pstReq )
		{
			fprintf( stderr, "create failed !!");
			return 0;
		}
		int down_ret = doRequire( pstPageInfo->pstReq, ntohl(inet_addr("127.0.0.1")), 2001, 5, &(pstPageInfo->pstRsp) );
		if( NULL == pstPageInfo->pstRsp )
		{
			fprintf( stderr, "get respones failed!\n" );
		}
		if( pstPageInfo->pstRsp->data.ack.LOGOUT_FLAG == 1 )
		{
			ShowAlert(search(portal_lcon, "Operation_Success"));
		}
	}
	
	
	if( cgiFormSubmitClicked("submit_user_manage") == cgiFormSuccess )
	{
		fprintf( fp,	"<script type='text/javascript'>");
		fprintf( fp,	"window.location.href = 'wp_authentication.cgi?UN=%s';\n", pstPageInfo->encry);
		fprintf( fp,	"</script>");
	}

	idx_begin = 0;
	idx_end = 0;

	int page_ret = 0;

	page_ret = USER_WEB_Pagination_get_range( totalNum, &pageNum, DATA_NUM_EVERYPAGE, &idx_begin, &idx_end );
	//fprintf( stderr, "idx_begin=%d--idx_end=%d--page_ret=%d--totalNum=%d\n" ,idx_begin,idx_end, page_ret,totalNum );
	if( -4 == page_ret )
	{
		pageNum++;
		ShowAlert(search(portal_lcon, "Page_Begin"));
	}
	if( -3 == page_ret )
	{
		pageNum--;
		ShowAlert(search(portal_lcon, "Page_end"));
	}
	
	
	pstPageInfo->pstReq = createRequirePkg( REQ_GET_USR_BY_INDEX_RANG, &idx_begin, &idx_end );
	if( NULL == pstPageInfo->pstReq )
	{
		fprintf( stderr, "create failed !!");
		return 0;
	}
	fprintf(stderr,"idx_begin=%d--idx_end=%d",idx_begin,idx_end);
	fprintf( stderr, "inet_addr(\"127.0.0.1\") = %d\n", ntohl(inet_addr("127.0.0.1")) );
	int do_ret = doRequire( pstPageInfo->pstReq, ntohl(inet_addr("127.0.0.1")), 2001, 5, &(pstPageInfo->pstRsp) );
	//fprintf( stderr, "do_ret=%d\n",do_ret );
	if( do_ret == -1 )
		{
			idx_begin = 0;
			idx_end = 0;
			return 0;
		}
	
	
	//计算出最后一页的页数
	totalNum = pstPageInfo->pstRsp->all_user_num;
   if( (totalNum%DATA_NUM_EVERYPAGE) == 0 || totalNum == 0 )
       LastPage = (totalNum/DATA_NUM_EVERYPAGE); //计算出最大页数
   else	
       LastPage = (totalNum/DATA_NUM_EVERYPAGE)+1; //计算出最大页数
	
	#if 1
	fprintf( stderr, "all_user_num=%d",pstPageInfo->pstRsp->all_user_num);
	fprintf( stderr, "len=%d",pstPageInfo->pstRsp->len);
	fprintf( stderr, "user_num_in_pkg=%d",pstPageInfo->pstRsp->data.ack.user_num_in_pkg);
	fprintf( stderr, "users[0].index=%d",pstPageInfo->pstRsp->data.ack.users[0].index);
	fprintf( stderr, "users[0].mac=%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",pstPageInfo->pstRsp->data.ack.users[0].usermac[0],pstPageInfo->pstRsp->data.ack.users[0].usermac[1],pstPageInfo->pstRsp->data.ack.users[0].usermac[2],pstPageInfo->pstRsp->data.ack.users[0].usermac[3],pstPageInfo->pstRsp->data.ack.users[0].usermac[4],pstPageInfo->pstRsp->data.ack.users[0].usermac[5]);
	fprintf( stderr, "users[0].username=%s",pstPageInfo->pstRsp->data.ack.users[0].username);
	fprintf( stderr, "users[0].ipaddr=%x",pstPageInfo->pstRsp->data.ack.users[0].ipaddr);
	fprintf( stderr, "users[0].input_octets=%lld",pstPageInfo->pstRsp->data.ack.users[0].input_octets);
	fprintf( stderr, "users[0].output_octets=%lld",pstPageInfo->pstRsp->data.ack.users[0].output_octets);
	#endif
	
	if( NULL == pstPageInfo->pstRsp )
	{
		fprintf( stderr, "get respones failed!\n" );
	}

	#if 1
		if(pstPageInfo->pstRsp->data.ack.user_num_in_pkg == 0 && pageNum > 1 )
		{
			ShowAlert(search(portal_lcon, "Page_end"));
			pageNum -- ;
		}
		if( pstPageInfo->pstRsp->data.ack.user_num_in_pkg < DATA_NUM_EVERYPAGE	)
		{
			idx_end = idx_begin + pstPageInfo->pstRsp->data.ack.user_num_in_pkg - 1;
		}
		//fprintf(stderr,"LA idx_end=%d",idx_end);
	#endif


	
	memset( search_content, 0, 30 );
	if( cgiFormSubmitClicked("search_but") == cgiFormSuccess )
	{
		int check_ret = 0;
		typeChoice = 0;
		cgiFormSelectSingle("search_type", search_type, 4, &typeChoice, 0);

		cgiFormStringNoNewlines("search_content", search_content, 30);
		//fprintf(stderr,"typeChoice=%d--search_content=%s",typeChoice,search_content);
		if( !strcmp(search_content, "") )
		{
			ShowAlert( search(portal_lauth, "search_not_null") );
			fprintf(stderr, "check_ret = %d",check_ret);
			return 0;
		}
		if( typeChoice == 2 )
		{
			check_ret = Input_IP_address_Check(search_content);
		}
		else if( typeChoice == 3 )
		{
			check_ret = Input_MAC_address_Check(search_content);
		}
		else if( typeChoice == 1 )
		{
			check_ret = Input_User_Name_Check(search_content);
		}
		else if( typeChoice == 0 )
		{
			check_ret = Input_User_Index_Check(search_content);
		}
		else
		{
			ShowAlert("Not pass search type!\n");
		}

		if( check_ret != 0 )
		{
			ShowAlert( search(portal_lauth, "input_char_error") );
			fprintf(stderr, "check_ret = %d",check_ret);
			return 0;
		}
		memset(search_content, 0, 30);
		cgiFormStringNoNewlines("search_content", search_content, 30);
		////////start search///////////////////////
		fprintf(stderr, "start enter searching---search_content =%s !\n",search_content);
		search_user_info( typeChoice, totalNum, search_content, &search_point , pstPageInfo);
		//fprintf(stderr, "search_point = %d---search_switch=%d",search_point,search_switch);

		
	}
	if( cgiFormSubmitClicked("ret_but") == cgiFormSuccess )
	{
		cgiFormStringNoNewlines("Pnum", PNtemp , 10);
		if( strcmp(PNtemp,"") != 0)
		{
	    	pageNum=atoi(PNtemp);
		}
		USER_WEB_Pagination_get_range( totalNum, &pageNum, DATA_NUM_EVERYPAGE, &idx_begin, &idx_end );
		//////////////数据修正///////////////////
		if(pstPageInfo->pstRsp->data.ack.user_num_in_pkg == 0 && pageNum > 1 )
		{
			ShowAlert(search(portal_lcon, "Page_end"));
			pageNum -- ;
		}
		if( pstPageInfo->pstRsp->data.ack.user_num_in_pkg < DATA_NUM_EVERYPAGE	)
		{
			idx_end = idx_begin + pstPageInfo->pstRsp->data.ack.user_num_in_pkg ;
		}
	}



	return 0;	
}
Exemplo n.º 8
0
int ShowQueryPage()
{
	struct list *lpublic;	/*解析public.txt文件的链表头*/
	struct list *lcontrol; 	/*解析help.txt文件的链表头*/
	lpublic=get_chain_head("../htdocs/text/public.txt");
    	lcontrol=get_chain_head("../htdocs/text/control.txt"); 	
  	char *encry=(char *)malloc(BUF_LEN);
  	char *str;
  //FILE *fp;
  //char lan[3];
	  char policer_encry[BUF_LEN]; 
	  char addn[N];        
	  char * mode=(char *)malloc(AMOUNT);
	  memset(mode,0,AMOUNT);
	  int i=0;   
	  int cl=1;
  	int retu=0;
  	int select_flag=0;
  	//char menu[21]="menulist";
  	char* i_char=(char *)malloc(10);
  	char * group=(char * )malloc(10);
  	memset(group,0,10);
  	char * QueryID=(char * )malloc(10);
  	memset(QueryID,0,10);
  	char * wrr_weight=(char * )malloc(10);
  	memset(wrr_weight,0,10);
  	int qos_num=0;
  	char * queue_mode=(char * )malloc(10);
  	memset(queue_mode,0,10);
	char * radiobutton=(char *)malloc(10);
	memset(radiobutton,0,10);
	cgiFormString("radiobutton", radiobutton, 10);

  	struct qos_info receive_qos[MAX_QOS_PROFILE];
  	struct query_info query_info[8];
  	int flag[8];
  	for(i=0;i<8;i++)
    	{
    		flag[i]=0;
    	}
	
  	for(i=0;i<MAX_QOS_PROFILE;i++)
	{
		receive_qos[i].profileindex=0;
		receive_qos[i].dp=0;
		receive_qos[i].up=0;
		receive_qos[i].tc=10;
		receive_qos[i].dscp=0;
	}
  	ccgi_dbus_init();
  	memset(encry,0,BUF_LEN);
  	if(cgiFormStringNoNewlines("UN", encry, BUF_LEN)!=cgiFormNotFound )  /*首次进入该页*/
  	{
    		str=dcryption(encry);
    		if(str==NULL)
    		{
	      		ShowErrorPage(search(lpublic,"ill_user")); 	 /*用户非法*/
	      		return 0;
		}
		strcpy(addn,str);
		memset(policer_encry,0,BUF_LEN);                   /*清空临时变量*/
  	}
  	else
  	{
	     cgiFormStringNoNewlines("encry_configqueue",encry,BUF_LEN);
	     cgiFormStringNoNewlines("group",group,10);
	     cgiFormStringNoNewlines("QueryID",QueryID,10);
	     cgiFormStringNoNewlines("wrr_weight",wrr_weight,10);
	     cgiFormStringNoNewlines("queue_mode",queue_mode,10);
	     cgiFormStringNoNewlines("CheckUsr",addn,10);
	}

  cgiHeaderContentType("text/html");
  fprintf(cgiOut,"<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>");
  fprintf(cgiOut,"<meta http-equiv=Content-Type content=text/html; charset=gb2312>");
  fprintf(cgiOut,"<title>%s</title>",search(lcontrol,"route_manage"));
  fprintf(cgiOut,"<link rel=stylesheet href=/style.css type=text/css>"\
  	"<style type=text/css>"\
  	  "#div1{ width:62px; height:18px; border:1px solid #666666; background-color:#f9f8f7;}"\
	  "#div2{ width:60px; height:15px; padding-left:5px; padding-top:3px}"\
	  "#link{ text-decoration:none; font-size: 12px}"\
  	".ShowPolicy {overflow-x:hidden;  overflow:auto; width: 580px; height: 236px; clip: rect( ); padding-top: 2px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px} "\
  	"</style>"\
  "</head>"\
    "<script type=\"text/javascript\">"\
			  "function popMenu(objId)"\
			  "{"\
				 "var obj = document.getElementById(objId);"\
				 "if (obj.style.display == 'none')"\
				 "{"\
				   "obj.style.display = 'block';"\
				 "}"\
				 "else"\
				 "{"\
				   "obj.style.display = 'none';"\
				 "}"\
			 "}"\
	"</script>"\
  "<body>");

 
  	 retu=checkuser_group(addn);

   	if(cgiFormSubmitClicked("submit_config_query") == cgiFormSuccess)
  	{
  		int ret=0;
  		if(strcmp(queue_mode,"sp")==0)
  		{
  			set_queue_scheduler(queue_mode);
  		}
  		else if(strcmp(queue_mode,"wrr")==0)
  		{
  			if(strcmp(wrr_weight,"")!=0)
  			{
     				set_queue_scheduler(queue_mode);
				if(strcmp(QueryID,"")!=0)
				{
	     			ret=set_wrr_queue(group,QueryID,wrr_weight,1);	     				
	     				
					if(ret==0)
					{
						ShowAlert(search(lcontrol,"config_queue_succ"));
					}
					else 
					{
						ShowAlert(search(lcontrol,"counterconfigfail"));
					}
				}
				else
				{
					ShowAlert(search(lcontrol,"pls_create_profile"));
				}
  			}
  			else
  			{
				ShowAlert(search(lcontrol,"weight_not_null"));
  			}
  				
  		}
  		else if(strcmp(queue_mode,"sp+wrr")==0)
  		{
  			char * temp=(char * )malloc(10);
  			memset(temp,0,10);
  			strcpy(temp,"hybrid");
			if(strcmp(radiobutton,"val")==0)
			{
	  			if(strcmp(wrr_weight,"")!=0)
	  			{
	     				set_queue_scheduler(temp);
					if(strcmp(QueryID,"")!=0)
					{
		   				ret=set_wrr_queue(group,QueryID,wrr_weight,2);		   				
						if(ret==0)
						{
							ShowAlert(search(lcontrol,"config_queue_succ"));
						}
						else 
						{
							ShowAlert(search(lcontrol,"counterconfigfail"));
						}
					}
					else
					{
						ShowAlert(search(lcontrol,"pls_create_profile"));
					}
				}
				else
				{
					ShowAlert(search(lcontrol,"weight_not_null"));
				}	
			}
			else if(strcmp(radiobutton,"sp")==0)
			{
				set_queue_scheduler(temp);
				if(strcmp(QueryID,"")!=0)
				{
					ret=set_wrr_queue(group,QueryID,"sp",2);					
				    if(ret==0)
					{
						ShowAlert(search(lcontrol,"config_queue_succ"));
					}
					else 
					{
						ShowAlert(search(lcontrol,"counterconfigfail"));
					}

				}
				else
				{
					ShowAlert(search(lcontrol,"pls_create_profile"));
				}
			}
			else
			{
				ShowAlert(search(lcontrol,"select_sp_weight"));
			}
  			free(temp);	
  		}
  	}

	show_qos_mode(mode);
  fprintf(cgiOut,"<form method=post>"\
  "<div align=center>"\
  "<table width=976 border=0 cellpadding=0 cellspacing=0>"\
  "<tr>"\
    "<td width=8 align=left valign=top background=/images/di22.jpg><img src=/images/youce4.jpg width=8 height=30/></td>"\
    "<td width=51 align=left valign=bottom background=/images/di22.jpg><img src=/images/youce33.jpg width=37 height=24/></td>"\
    "<td width=153 align=left valign=bottom background=/images/di22.jpg><font id=titleen>QOS</font><font id=%s> %s</font></td>",search(lpublic,"title_style"),search(lpublic,"management"));
    fprintf(cgiOut,"<td width=690 align=right valign=bottom background=/images/di22.jpg>");
    	  fprintf(cgiOut,"<table width=130 border=0 cellspacing=0 cellpadding=0>"\
          "<tr>"\
          "<td width=62 align=center><input id=but type=submit name=submit_config_query style=background-image:url(/images/%s) value=""></td>",search(lpublic,"img_ok"));		  
          
		  if(cgiFormSubmitClicked("submit_config_query") != cgiFormSuccess)
		  {
            fprintf(cgiOut,"<td width=62 align=left><a href=wp_qosModule.cgi?UN=%s target=mainFrame><img src=/images/%s border=0 width=62 height=20/></a></td>",encry,search(lpublic,"img_cancel"));
           
            }
		  else                                         
     		fprintf(cgiOut,"<td width=62 align=left><a href=wp_qosModule.cgi?UN=%s target=mainFrame><img src=/images/%s border=0 width=62 height=20/></a></td>",encry,search(lpublic,"img_cancel"));
		  fprintf(cgiOut,"</tr>"\
          "</table>");
	fprintf(cgiOut,"</td>"\
    "<td width=74 align=right valign=top background=/images/di22.jpg><img src=/images/youce3.jpg width=31 height=30/></td>"\
  "</tr>"\
  "<tr>"\
    "<td colspan=5 align=center valign=middle><table width=976 border=0 cellpadding=0 cellspacing=0 bgcolor=#f0eff0>"\
      "<tr>"\
        "<td width=12 align=left valign=top background=/images/di888.jpg>&nbsp;</td>"\
        "<td width=948><table width=947 border=0 cellspacing=0 cellpadding=0>"\
            "<tr height=4 valign=bottom>"\
              "<td width=120>&nbsp;</td>"\
              "<td width=827 valign=bottom><img src=/images/bottom_05.gif width=827 height=4/></td>"\
            "</tr>"\
            "<tr>"\
              "<td><table width=120 border=0 cellspacing=0 cellpadding=0>"\
                   "<tr height=25>"\
                    "<td id=tdleft>&nbsp;</td>"\
                  "</tr>");       			
                  
     			fprintf(cgiOut,"<tr height=26>"\
     			"<td align=left id=tdleft background=/images/bottom_bg.gif style=\"border-right:0\"><font id=%s>%s</font></td>",search(lpublic,"menu_san"),search(lcontrol,"config_queue_list"));   /*突出显示*/
     			fprintf(cgiOut,"</tr>");
				int rowsCount=0;
				if(retu==0)
					rowsCount=16;
				else rowsCount=12;
				for(i=0;i<rowsCount+2;i++)
					{
						fprintf(cgiOut,"<tr height=25>"\
						  "<td id=tdleft>&nbsp;</td>"\
						"</tr>");
					}
				  fprintf(cgiOut,"</table>"\
              "</td>"\
              "<td align=left valign=top style=\"background-color:#ffffff; border-right:1px solid #707070; padding-left:30px; padding-top:10px\">"\
						"<table width=640 height=310 border=0 cellspacing=0 cellpadding=0>");
				  fprintf(cgiOut,"<tr height='35'>\n"\
				  				"<td style=\"font-size:14px\"><font color='red'><b>%s</b></font></td>"\
				  			  "</tr>\n",search(lcontrol,mode));
						if(retu==0)
						{
    						fprintf(cgiOut,"<tr>"\
    						"<td id=sec1 style=\"border-bottom:2px solid #53868b;font-size:14px\">%s</td>",search(lcontrol,"config_query_mode"));
    						fprintf(cgiOut,"</tr>"\
    						"<tr>"\
    						"<td><table frame=below rules=rows width=440 height=70 border=1>");
    						show_qos_profile(receive_qos,&qos_num,lcontrol);
    						for(i=0;i<qos_num;i++)
    						{
    							if(receive_qos[i].tc!=10)
    							{
    								flag[receive_qos[i].tc]=1;
								select_flag++;
    							}
    						}
    						fprintf(cgiOut,"<tr height=25 align=left  style=padding-top:8px>");
    						    fprintf(cgiOut,"<td id=td1 width=110>%s:</td>",search(lcontrol,"queue_mode"));
    						    fprintf(cgiOut,"<td  align=left style=padding-left:10px colspan=7><select name=queue_mode onchange=\"javascript:this.form.submit();\">");
    						    for(i=0;i<((get_product_id()==PRODUCT_ID_AU3K_BCM)?2:3);i++)
    							if(strcmp(Queue_Scheduler[i],queue_mode)==0)				/*显示上次选中的*/
    								fprintf(cgiOut,"<option value=%s selected=selected>%s",Queue_Scheduler[i],Queue_Scheduler[i]);
    							else				
    								fprintf(cgiOut,"<option value=%s>%s",Queue_Scheduler[i],Queue_Scheduler[i]);
    						    fprintf(cgiOut,"</select>");
    						    fprintf(cgiOut,"</td>");
    						    int Queue_Schedulerchoice=0;
    							cgiFormSelectSingle("queue_mode", Queue_Scheduler, 3, &Queue_Schedulerchoice, 0);
    						   	fprintf(cgiOut,"</tr>");
    							if(Queue_Schedulerchoice==2 || Queue_Schedulerchoice==1)
    							{
    								fprintf(cgiOut,"<tr height=25 align=left  style=padding-top:8px>");
    								fprintf(cgiOut,"<td  align=left style=padding-left:10px colspan=3>");
								if(get_product_id()!=PRODUCT_ID_AU3K_BCM)
								{
									fprintf(cgiOut,"<select name=group>");
        						    			fprintf(cgiOut,"<option value=%s>%s","group1","group1");
        						    			fprintf(cgiOut,"<option value=%s>%s","group2","group2");
        						    		fprintf(cgiOut,"</select>");
								}
								else
								{
									fprintf(cgiOut,"<input type=hidden name=group value=group1><b>group1</b>");
								}
        						    	fprintf(cgiOut,"</td>");
        						    fprintf(cgiOut,"<td id=td1>%s:</td>",search(lcontrol,"queue_TC"));
    								fprintf(cgiOut,"<td  align=left style=padding-left:10px colspan=3>\n");
								if(select_flag!=0)
								{
									fprintf(cgiOut,"<select name=QueryID>");
    									for(i=0;i<8;i++)
    									{
    										if(flag[i]==1)
    										{
    											fprintf(cgiOut,"<option value=%d>%d",i,i);
    										}
    									}
        						    		fprintf(cgiOut,"</select>");
								}
								else
								{
									fprintf(cgiOut,"<font color='red'>%s</font>",search(lcontrol,"not_create_qos_profile"));
								}
        						    fprintf(cgiOut,"</td>");
//***************************************************changed here**********************************************************
								if(Queue_Schedulerchoice==1)
								{
	    								fprintf(cgiOut,"<td id=td1>%s:</td>",search(lcontrol,"weight"));
	    								fprintf(cgiOut,"<td><input type=text name=wrr_weight size=8></td>");
								}
								else if(Queue_Schedulerchoice==2)
								{
	    								fprintf(cgiOut,"<td id=td1><input type=radio name=radiobutton value='val' checked />%s:</td>",search(lcontrol,"weight"));
	    								fprintf(cgiOut,"<td><input type=text name=wrr_weight size=8></td>");
									fprintf(cgiOut,"<td id=td1><input type=radio name=radiobutton value='sp' />sp</td>");
								}
//**********************************************************************************************************************************************************
    								fprintf(cgiOut,"</tr>");
    							}
    						fprintf(cgiOut,"</table>"\
    						"</td>"\
    						"</tr>");
						}
						fprintf(cgiOut,"<tr style=padding-top:18px>"\
						"<td id=sec1 style=\"border-bottom:2px solid #53868b;font-size:14px\">%s</td>",search(lcontrol,"config_queue_list"));
						fprintf(cgiOut,"</tr>"\
						 "<tr>"\
						   "<td align=left valign=top style=padding-top:18px>"\
						   "<div class=ShowPolicy><table width=320 border=1 frame=below rules=rows bordercolor=#cccccc cellspacing=0 cellpadding=0>");
						   fprintf(cgiOut,"<tr height=30 bgcolor=#eaeff9 style=font-size:14px  id=td1  align=left>"\
							 "<th width=90><font id=%s>%s</font></th>", search(lpublic,"menu_thead"),search(lcontrol,"queue_TC"));
							 fprintf(cgiOut,"<th width=120><font id=%s>%s</font></th>", search(lpublic,"menu_thead"),search(lcontrol,"Scheduling_Group"));
							 fprintf(cgiOut,"<th width=70><font id=%s>%s</font></th>", search(lpublic,"menu_thead"),search(lcontrol,"weight"));
							 fprintf(cgiOut,"</tr>");
							 for(i=0;i<8;i++)
			                              {
			                              	flag[i]=0;
			                              	query_info[i].QID=0;
			                              	query_info[i].Scheduling_group=(char * )malloc(10);
			                              	memset(query_info[i].Scheduling_group,0,10);
			                              	query_info[i].weight=0;
			                              }
							show_queue(query_info);
							for(i=0;i<8;i++)
							{
								/*memset(menu,0,21);
							  	strcpy(menu,"menulist");
							  	sprintf(i_char,"%d",i+1);
							  	strcat(menu,i_char);*/

								fprintf(cgiOut,"<tr height=25 bgcolor=%s align=left>",setclour(cl));
								 fprintf(cgiOut,"<td>%u</td>",query_info[i].QID);
								 fprintf(cgiOut,"<td>%s</td>",query_info[i].Scheduling_group);
								 fprintf(cgiOut,"<td>%u</td>",query_info[i].weight); 
								 fprintf(cgiOut,"</tr>");
								 cl=!cl;
							}
							 
						  	fprintf(cgiOut,"</table></div>"\
							 "</td>"\
						   "</tr>"\
						 
						"<tr>"\
						"<td id=sec1 style=\"border-bottom:2px solid #53868b;font-size:14px\">%s</td>",search(lpublic,"description"));
						fprintf(cgiOut,"</tr>"\
						 "<tr height=25 style=padding-top:2px>"\
			   			"<td style=font-size:14px;color:#FF0000>%s</td>",search(lcontrol,"queue_TC_des"));
			   			fprintf(cgiOut,"</tr>"\
			   			
						/*"<tr>"\
						"<td>"\
						"<table width=430 style=padding-top:2px>"\
						"<tr>");
						sprintf(pageNumCA,"%d",pageNum+1);
						sprintf(pageNumCD,"%d",pageNum-1);
						if(cgiFormSubmitClicked("submit_config_query") != cgiFormSuccess)
							{
								fprintf(cgiOut,"<td align=center style=padding-top:2px><a href=wp_srouter.cgi?UN=%s&PN=%s&SN=%s>%s</td>",encry,pageNumCA,"PageDown",search(lcontrol,"page_down"));
								fprintf(cgiOut,"<td align=center style=padding-top:2px><a href=wp_srouter.cgi?UN=%s&PN=%s&SN=%s>%s</td>",encry,pageNumCD,"PageUp",search(lcontrol,"page_up"));
							}
						else if(cgiFormSubmitClicked("submit_config_query") == cgiFormSuccess)
							{
								fprintf(cgiOut,"<td align=center style=padding-top:2px><a href=wp_srouter.cgi?UN=%s&PN=%s&SN=%s>%s</td>",policer_encry,pageNumCA,"PageDown",search(lcontrol,"page_down"));
								fprintf(cgiOut,"<td align=center style=padding-top:2px><a href=wp_srouter.cgi?UN=%s&PN=%s&SN=%s>%s</td>",policer_encry,pageNumCD,"PageUp",search(lcontrol,"page_up"));  
							}
						fprintf(cgiOut,"</tr></table></td>"\
						"</tr>"\*/
						 "<tr>");
						 if(cgiFormSubmitClicked("submit_config_query") != cgiFormSuccess)
						 {
						   fprintf(cgiOut,"<td colspan=6><input type=hidden name=encry_configqueue value=%s></td>",encry);
						   fprintf(cgiOut,"<td><input type=hidden name=CheckUsr value=%s></td>",addn);
						 }
						 else if(cgiFormSubmitClicked("submit_config_query") == cgiFormSuccess)
							 {
							   fprintf(cgiOut,"<td colspan=6><input type=hidden name=encry_configqueue value=%s></td>",encry);
							   fprintf(cgiOut,"<td><input type=hidden name=CheckUsr value=%s></td>",addn);
							 }
						 fprintf(cgiOut,"</tr>"\
					  "</table>"\

              "</td>"\
            "</tr>"\
            "<tr height=4 valign=top>"\
              "<td width=120 height=4 align=right valign=top><img src=/images/bottom_07.gif width=1 height=10/></td>"\
              "<td width=827 height=4 valign=top bgcolor=#FFFFFF><img src=/images/bottom_06.gif width=827 height=15/></td>"\
            "</tr>"\
          "</table>"\
        "</td>"\
        "<td width=15 background=/images/di999.jpg>&nbsp;</td>"\
      "</tr>"\
    "</table></td>"\
  "</tr>"\
  "<tr>"\
    "<td colspan=3 align=left valign=top background=/images/di777.jpg><img src=/images/di555.jpg width=61 height=62/></td>"\
    "<td align=left valign=top background=/images/di777.jpg>&nbsp;</td>"\
    "<td align=left valign=top background=/images/di777.jpg><img src=/images/di666.jpg width=74 height=62/></td>"\
  "</tr>"\
"</table>"\
"</div>"\
"</form>"\
"</body>"\
"</html>");  
free(encry);
free(i_char);
for(i=0;i<8;i++)
{
	free(query_info[i].Scheduling_group);
}
free(group);
free(QueryID);
free(wrr_weight);
free(queue_mode);
release(lpublic);  
release(lcontrol);
free(mode);
return 0;
}
Exemplo n.º 9
0
int cgiMain()
{
	
	
	int ret = session_read(name);
	if(ret != 1)
	{
		cgiHeaderContentType("text/html;charset=gb2312");
		fprintf(cgiOut, "<HTML><HEAD>\n");
		fprintf(cgiOut,	"</HEAD><BODY>\n");
		fprintf(cgiOut, "<script type=\"text/javascript\">\n");
		fprintf(cgiOut, "window.alert(\"用户尚未登录,请重新登录(错误码:%d)!\");\n", ret);
		fprintf(cgiOut, "window.location.href=\"../login.html\";\n");
		fprintf(cgiOut, "</script>\n");
		fprintf(cgiOut, "</BODY>\n");
		fprintf(cgiOut, "</HTML>\n");
		return 0;
	}
	
	ret = its_conf_gpio_query(name, &con_gpio);
	
	
	
	cgiHeaderContentType("text/html;charset=gb2312");
	fprintf(cgiOut, "<style type=\"text/css\">\n");
	fprintf(cgiOut, "<!--\n");
	fprintf(cgiOut, "body {\n");
	fprintf(cgiOut, "	margin-left: 0px;\n");
	fprintf(cgiOut, "	margin-top: 0px;\n");
	fprintf(cgiOut, "	margin-right: 0px;\n");
	fprintf(cgiOut, "	margin-bottom: 0px;\n");
	fprintf(cgiOut, "	background-color: #F8F9FA;\n");
	fprintf(cgiOut, "}\n");
	fprintf(cgiOut, "-->\n");
	fprintf(cgiOut, "</style>\n");
	fprintf(cgiOut, "<link href=\"../images/skin.css\" rel=\"stylesheet\" type=\"text/css\" />\n");
	//fprintf(cgiOut, "<HEAD><meta http-equiv=\"refresh\" content=\"1\">\n");
	fprintf(cgiOut,	"</HEAD>\n");
	fprintf(cgiOut, "<body>\n");
	
	if(ret != QUERY_OK)
	{
		fprintf(cgiOut, "<script type=\"text/javascript\">\n");
		fprintf(cgiOut, "window.alert(\"(错误码:%d)!\");\n", ret);
		fprintf(cgiOut, "</script>\n");		
	}else if (cgiFormSubmitClicked("setting") == cgiFormSuccess){


		char *str1[2] = {"0","1"};
		int  i;/*must be int, f**k*/
		cgiFormSelectSingle("output1", str1, sizeof(str1)/sizeof(str1[0]), &i, 0);
		con_gpio.output[0]= i;

		cgiFormSelectSingle("output2", str1, sizeof(str1)/sizeof(str1[0]), &i, 0);
		con_gpio.output[1]= i;

		cgiFormSelectSingle("output3", str1, sizeof(str1)/sizeof(str1[0]), &i, 0);
		con_gpio.output[2]= i;

      cgiFormSelectSingle("output4", str1, sizeof(str1)/sizeof(str1[0]), &i, 0);
		con_gpio.output[3]= i;
      

		

#if 0
		its_conf_gpio_set(name,&con_gpio);
#else
		if (GPIO_SET_OK!=its_conf_gpio_set(name,&con_gpio)){
	
			fprintf(cgiOut, "<script type=\"text/javascript\">\n");
			fprintf(cgiOut, "window.alert(\"提交失败(错误码:%d)!\");\n", ret);
			fprintf(cgiOut, "</script>\n");
			
			//提交失败后需要重新获取参数
			bzero(&con_gpio, sizeof(con_gpio));
			its_conf_gpio_query(name, &con_gpio);
		}
		else
		{
			//fprintf(cgiOut, "[%s][%s][%s][%s]\n", con_sys.host_name, con_sys.host_pos, con_sys.host_id, con_sys.description);
			fprintf(cgiOut, "<script type=\"text/javascript\">\n");
			fprintf(cgiOut, "window.alert(\"提交成功!\");\n");
			fprintf(cgiOut, "</script>\n");
		}

#endif
	}
		
	
	
SHOW:	
	fprintf(cgiOut, "<table width=\"100%%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
	fprintf(cgiOut, "  <tr>\n");
	fprintf(cgiOut, "    <td width=\"17\" height=\"29\" valign=\"top\" background=\"../images/mail_leftbg.gif\"><img src=\"../images/left-top-right.gif\" width=\"17\" height=\"29\" /></td>\n");
	fprintf(cgiOut, "    <td width=\"935\" height=\"29\" valign=\"top\" background=\"../images/content-bg.gif\"><table width=\"100%%\" height=\"31\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"left_topbg\" id=\"table2\">\n");
	fprintf(cgiOut, "      <tr>\n");
	fprintf(cgiOut, "        <td height=\"31\"><div class=\"titlebt\">传感器设置</div></td>\n");
	fprintf(cgiOut, "      </tr>\n");
	fprintf(cgiOut, "    </table></td>\n");
	fprintf(cgiOut, "    <td width=\"16\" valign=\"top\" background=\"../images/mail_rightbg.gif\"><img src=\"../images/nav-right-bg.gif\" width=\"16\" height=\"29\" /></td>\n");
	fprintf(cgiOut, "  </tr>\n");
	fprintf(cgiOut, "  <tr>\n");
	fprintf(cgiOut, "    <td height=\"71\" valign=\"middle\" background=\"../images/mail_leftbg.gif\">&nbsp;</td>\n");
	fprintf(cgiOut, "    <td valign=\"top\" bgcolor=\"#F7F8F9\"><table width=\"100%%\" height=\"138\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
	fprintf(cgiOut, "      <tr>\n");
	fprintf(cgiOut, "        <td height=\"13\" valign=\"top\">&nbsp;</td>\n");
	fprintf(cgiOut, "      </tr>\n");
	fprintf(cgiOut, "      <tr>\n");
	fprintf(cgiOut, "        <td valign=\"top\"><table width=\"98%%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">\n");
	fprintf(cgiOut, "          <tr>\n");
	fprintf(cgiOut, "            <td class=\"left_txt\"></td>\n");
	fprintf(cgiOut, "          </tr>\n");
	fprintf(cgiOut, "          <tr>\n");
	fprintf(cgiOut, "            <td height=\"20\"><table width=\"100%%\" height=\"1\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#CCCCCC\">\n");
	fprintf(cgiOut, "              <tr>\n");
	fprintf(cgiOut, "                <td></td>\n");
	fprintf(cgiOut, "              </tr>\n");
	fprintf(cgiOut, "            </table></td>\n");
	fprintf(cgiOut, "          </tr>\n");
	fprintf(cgiOut, "          <tr>\n");
	fprintf(cgiOut, "            <td><table width=\"100%%\" height=\"55\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
	fprintf(cgiOut, "              <tr>\n");
	fprintf(cgiOut, "                <td width=\"10%%\" height=\"55\" valign=\"middle\"><img src=\"../images/title.gif\" width=\"54\" height=\"55\"></td>\n");
	fprintf(cgiOut, "                <td width=\"90%%\" valign=\"top\"><span class=\"left_txt2\"></span><span class=\"left_txt3\"></span><span class=\"left_txt2\"></span><br>\n");
	fprintf(cgiOut, "                          <span class=\"left_txt2\"></span><span class=\"left_txt3\"></span><span class=\"left_txt2\"></span><span class=\"left_txt3\"></span><span class=\"left_txt2\"> </span></td>\n");
	fprintf(cgiOut, "              </tr>\n");
	fprintf(cgiOut, "            </table></td>\n");
	fprintf(cgiOut, "          </tr>\n");
	fprintf(cgiOut, "          <tr>\n");
	fprintf(cgiOut, "            <td>&nbsp;</td>\n");
	fprintf(cgiOut, "          </tr>\n");
	fprintf(cgiOut, "          <tr>\n");
	fprintf(cgiOut, "            <td><table width=\"100%%\" height=\"31\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"nowtable\">\n");
	fprintf(cgiOut, "              <tr>\n");
	fprintf(cgiOut, "                <td class=\"left_bt2\">&nbsp;&nbsp;&nbsp;&nbsp;报警信号输入状态</td>\n");
	fprintf(cgiOut, "              </tr>\n");
	fprintf(cgiOut, "            </table></td>\n");
	fprintf(cgiOut, "          </tr>\n");
	fprintf(cgiOut, "          <tr>\n");
	fprintf(cgiOut, "            <td><table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n");
	fprintf(cgiOut, "              <form name=\"form1\" method=\"POST\" action=\"");
	fprintf(cgiOut, "\">\n");
	

	fprintf(cgiOut, "                </tr>\n");
	fprintf(cgiOut, "                <tr>\n");
	fprintf(cgiOut, "                  <td height=\"30\" align=\"right\" bgcolor=\"#F7F8F9\" class=\"left_txt2\">Alarm1</td>\n");
	fprintf(cgiOut, "                  <td bgcolor=\"#F7F8F9\">&nbsp;</td>\n");
	fprintf(cgiOut, "                  <td height=\"30\" bgcolor=\"#F7F8F9\"><label>\n");
	
	show_alarm(1);
	fprintf(cgiOut, "                </tr>\n");
	fprintf(cgiOut, "                <tr>\n");
	fprintf(cgiOut, "                  <td height=\"30\" align=\"right\" bgcolor=\"#F7F8F9\" class=\"left_txt2\">Alarm2</td>\n");
	fprintf(cgiOut, "                  <td bgcolor=\"#F7F8F9\">&nbsp;</td>\n");
	fprintf(cgiOut, "                  <td height=\"30\" bgcolor=\"#F7F8F9\"><label>\n");
	show_alarm(2);
	fprintf(cgiOut, "                </tr>\n");
	fprintf(cgiOut, "                <tr>\n");
	fprintf(cgiOut, "                  <td height=\"30\" align=\"right\" bgcolor=\"#F7F8F9\" class=\"left_txt2\">Alarm3</td>\n");
	fprintf(cgiOut, "                  <td bgcolor=\"#F7F8F9\">&nbsp;</td>\n");
	fprintf(cgiOut, "                  <td height=\"30\" bgcolor=\"#F7F8F9\"><label>\n");
	show_alarm(3);
   /*
   fprintf(cgiOut, "                </tr>\n");
	fprintf(cgiOut, "                <tr>\n");
	fprintf(cgiOut, "                  <td height=\"30\" align=\"right\" bgcolor=\"#F7F8F9\" class=\"left_txt2\">Alarm4</td>\n");
	fprintf(cgiOut, "                  <td bgcolor=\"#F7F8F9\">&nbsp;</td>\n");
	fprintf(cgiOut, "                  <td height=\"30\" bgcolor=\"#F7F8F9\"><label>\n");
	show_alarm(4);
	fprintf(cgiOut, "                </tr>\n");
	fprintf(cgiOut, "                <tr>\n");
	fprintf(cgiOut, "                  <td height=\"30\" align=\"right\" bgcolor=\"#F7F8F9\" class=\"left_txt2\">Alarm5</td>\n");
	fprintf(cgiOut, "                  <td bgcolor=\"#F7F8F9\">&nbsp;</td>\n");
	fprintf(cgiOut, "                  <td height=\"30\" bgcolor=\"#F7F8F9\"><label>\n");
	show_alarm(5);
	fprintf(cgiOut, "                </tr>\n");
	fprintf(cgiOut, "                <tr>\n");
	fprintf(cgiOut, "                  <td height=\"30\" align=\"right\" bgcolor=\"#F7F8F9\" class=\"left_txt2\">Alarm6</td>\n");
	fprintf(cgiOut, "                  <td bgcolor=\"#F7F8F9\">&nbsp;</td>\n");
	fprintf(cgiOut, "                  <td height=\"30\" bgcolor=\"#F7F8F9\"><label>\n");
	show_alarm(6);
	fprintf(cgiOut, "                </tr>\n");
	fprintf(cgiOut, "                <tr>\n");
	fprintf(cgiOut, "                  <td height=\"30\" align=\"right\" bgcolor=\"#F7F8F9\" class=\"left_txt2\">Alarm7</td>\n");
	fprintf(cgiOut, "                  <td bgcolor=\"#F7F8F9\">&nbsp;</td>\n");
	fprintf(cgiOut, "                  <td height=\"30\" bgcolor=\"#F7F8F9\"><label>\n");
	show_alarm(7);
	fprintf(cgiOut, "                </tr>\n");
	fprintf(cgiOut, "                <tr>\n");
	fprintf(cgiOut, "                  <td height=\"30\" align=\"right\" bgcolor=\"#F7F8F9\" class=\"left_txt2\">Alarm8</td>\n");
	fprintf(cgiOut, "                  <td bgcolor=\"#F7F8F9\">&nbsp;</td>\n");
	fprintf(cgiOut, "                  <td height=\"30\" bgcolor=\"#F7F8F9\"><label>\n");
	show_alarm(8);
   */

	fprintf(cgiOut, "                    </label></td>\n");
	fprintf(cgiOut, "                </tr>\n");
	fprintf(cgiOut, "                <tr>\n");
	fprintf(cgiOut, "                  <td height=\"30\" align=\"right\" class=\"left_txt2\">Output1:</td>\n");
	fprintf(cgiOut, "                  <td>&nbsp;</td>\n");
	fprintf(cgiOut, "                  <td height=\"30\"><label>\n");
	show_output1();

	fprintf(cgiOut, "                    </label></td>\n");
	fprintf(cgiOut, "                </tr>\n");
	fprintf(cgiOut, "                <tr>\n");
	fprintf(cgiOut, "                  <td height=\"30\" align=\"right\" class=\"left_txt2\">Output2:</td>\n");
	fprintf(cgiOut, "                  <td>&nbsp;</td>\n");
	fprintf(cgiOut, "                  <td height=\"30\"><label>\n");
	show_output2();

	fprintf(cgiOut, "                    </label></td>\n");
	fprintf(cgiOut, "                </tr>\n");
	fprintf(cgiOut, "                <tr>\n");
	fprintf(cgiOut, "                  <td height=\"30\" align=\"right\" class=\"left_txt2\">Output3:</td>\n");
	fprintf(cgiOut, "                  <td>&nbsp;</td>\n");
	fprintf(cgiOut, "                  <td height=\"30\"><label>\n");
	show_output3();

   fprintf(cgiOut, "                    </label></td>\n");
	fprintf(cgiOut, "                </tr>\n");
	fprintf(cgiOut, "                <tr>\n");
	fprintf(cgiOut, "                  <td height=\"30\" align=\"right\" class=\"left_txt2\">Output4:</td>\n");
	fprintf(cgiOut, "                  <td>&nbsp;</td>\n");
	fprintf(cgiOut, "                  <td height=\"30\"><label>\n");
	show_output4();

	fprintf(cgiOut, "                <tr>\n");
	fprintf(cgiOut, "                  <td height=\"30\" colspan=\"4\" align=\"center\" class=\"left_txt2\"><input type=\"submit\" value=\"设置\" name=\"setting\" /></td>\n");
	fprintf(cgiOut, "                </tr>\n");
	
	fprintf(cgiOut, "</body>\n");
}
Exemplo n.º 10
0
int ShowWlannewPage(char *m,char *wid,char *n,struct list *lpublic,struct list *lwlan)
{  
  int i = 0,result = 0,macPolicyChoice = 0;  
  DCLI_WLAN_API_GROUP *WLANINFO = NULL;
  int wnum = 0;             /*存放wlan的个数*/
  char *endptr = NULL;
  int wlan_id = 0;
  char select_insid[10] = { 0 };
  instance_parameter *paraHead1 = NULL,*paraHead2 = NULL;
  instance_parameter *pq = NULL;
  char temp[10] = { 0 };
  dbus_parameter ins_para;
  cgiHeaderContentType("text/html");
  fprintf(cgiOut,"<html xmlns=\"http://www.w3.org/1999/xhtml\"><head>");
  fprintf(cgiOut,"<meta http-equiv=Content-Type content=text/html; charset=gb2312>");
  fprintf(cgiOut,"<title>Wlan</title>");
  fprintf(cgiOut,"<link rel=stylesheet href=/style.css type=text/css>"\
  "</head>"\
  "<script src=/instanceid_onchange.js>"\
  "</script>"\
  "<body>");  
  memset(select_insid,0,sizeof(select_insid));
  cgiFormStringNoNewlines( "INSTANCE_ID", select_insid, 10 );
  if(strcmp(select_insid,"")==0)
  { 
	list_instance_parameter(&paraHead1, INSTANCE_STATE_WEB); 
	if(paraHead1)
	{
		snprintf(select_insid,sizeof(select_insid)-1,"%d-%d-%d",paraHead1->parameter.slot_id,paraHead1->parameter.local_id,paraHead1->parameter.instance_id);
	} 
  }  
  else
  {
	get_slotID_localID_instanceID(select_insid,&ins_para);	
	get_instance_dbus_connection(ins_para, &paraHead1, INSTANCE_STATE_WEB);
  }
  if(cgiFormSubmitClicked("wlannew_apply") == cgiFormSuccess)
  {
  	if(paraHead1)
	{
		NewWlan(paraHead1,lpublic,lwlan);
	} 
  }
	fprintf(cgiOut,"<form>"\
  "<div align=center>"\
  "<table width=976 border=0 cellpadding=0 cellspacing=0>"\
  "<tr>"\
    "<td width=8 align=left valign=top background=/images/di22.jpg><img src=/images/youce4.jpg width=8 height=30/></td>"\
    "<td width=51 align=left valign=bottom background=/images/di22.jpg><img src=/images/youce33.jpg width=37 height=24/></td>"\
    "<td width=153 align=left valign=bottom id=titleen background=/images/di22.jpg>WLAN</td>"\
    "<td width=690 align=right valign=bottom background=/images/di22.jpg>");
	  
    	  fprintf(cgiOut,"<table width=155 border=0 cellspacing=0 cellpadding=0>"\
          "<tr>"\
          "<td width=62 align=center><input id=but type=submit name=wlannew_apply style=background-image:url(/images/%s) value=""></td>",search(lpublic,"img_ok"));			  
          fprintf(cgiOut,"<td width=62 align=center><a href=wp_wlan.cgi?UN=%s target=mainFrame><img src=/images/%s border=0 width=62 height=20/></a></td>",m,search(lpublic,"img_cancel"));
		  fprintf(cgiOut,"</tr>"\
          "</table>");
      fprintf(cgiOut,"</td>"\
    "<td width=74 align=right valign=top background=/images/di22.jpg><img src=/images/youce3.jpg width=31 height=30/></td>"\
  "</tr>"\
  "<tr>"\
    "<td colspan=5 align=center valign=middle><table width=976 border=0 cellpadding=0 cellspacing=0 bgcolor=#f0eff0>"\
      "<tr>"\
        "<td width=12 align=left valign=top background=/images/di888.jpg>&nbsp;</td>"\
        "<td width=948><table width=947 border=0 cellspacing=0 cellpadding=0>"\
            "<tr height=4 valign=bottom>"\
              "<td width=120>&nbsp;</td>"\
              "<td width=827 valign=bottom><img src=/images/bottom_05.gif width=827 height=4/></td>"\
            "</tr>"\
            "<tr>"\
              "<td><table width=120 border=0 cellspacing=0 cellpadding=0>"\
                   "<tr height=25>"\
                    "<td id=tdleft>&nbsp;</td>"\
                  "</tr>");	          
  				    fprintf(cgiOut,"<tr height=25>"\
  					  "<td align=left id=tdleft><a href=wp_wlanlis.cgi?UN=%s target=mainFrame class=top><font id=yingwen_san>WLAN</font><font id=%s> %s</font></a></td>",m,search(lpublic,"menu_san"),search(lpublic,"list"));                       
                    fprintf(cgiOut,"</tr>");
					fprintf(cgiOut,"<tr height=25>"\
					  "<td align=left id=tdleft><a href=wp_wlannew.cgi?UN=%s target=mainFrame class=top><font id=%s>%s</font><font id=yingwen_san> WLAN</font></a></td>",m,search(lpublic,"menu_san"),search(lpublic,"create"));                       
                    fprintf(cgiOut,"</tr>"\
  				    "<tr height=26>"\
                      "<td align=left id=tdleft background=/images/bottom_bg.gif style=\"border-right:0\"><font id=yingwen_san>MAC</font><font id=%s> %s</font></td>",search(lpublic,"menu_san"),search(lwlan,"mac_filter"));   /*突出显示*/
					fprintf(cgiOut,"</tr>");
                  for(i=0;i<1;i++)
	              {
  				    fprintf(cgiOut,"<tr height=25>"\
                      "<td id=tdleft>&nbsp;</td>"\
                    "</tr>");
	              }
                fprintf(cgiOut,"</table>"\
              "</td>"\
              "<td align=left style=\"background-color:#ffffff; border-right:1px solid #707070; padding-left:30px\">"\
              "<table width=370 border=0 cellspacing=0 cellpadding=0>");
				if(paraHead1)
				{
					result=show_wlan_list(paraHead1->parameter,paraHead1->connection,&WLANINFO);  
				} 
				if(result == 1)
				{
					wnum = WLANINFO->wlan_num;
				}
  fprintf(cgiOut,"<tr height=30>"\
	"<td>%s ID:</td>",search(lpublic,"instance"));
	fprintf(cgiOut,"<td align=left colspan=2>"\
	  "<select name=instance_id id=instance_id style=width:80px onchange=instanceid_change(this,\"wp_wlanbw.cgi\",\"%s\")>",m);	  
	  list_instance_parameter(&paraHead2, INSTANCE_STATE_WEB);	 
	  for(pq=paraHead2;(NULL != pq);pq=pq->next)
	  {
		 memset(temp,0,sizeof(temp));
		 snprintf(temp,sizeof(temp)-1,"%d-%d-%d",pq->parameter.slot_id,pq->parameter.local_id,pq->parameter.instance_id);
	  
		 if(strcmp(select_insid,temp) == 0)
		   fprintf(cgiOut,"<option value='%s' selected=selected>%s",temp,temp);
		 else
		   fprintf(cgiOut,"<option value='%s'>%s",temp,temp);
	  } 		  
	  free_instance_parameter_list(&paraHead2);
	  fprintf(cgiOut,"</select>"\
	"</td>"\
  "</tr>"\
  "<tr height=30>"\
    "<td width=70>WLAN ID:</td>"\
    "<td width=150 align=left><select name=wlan_id id=wlan_id style=width:80px>");
    wlan_id= strtoul(wid,&endptr,10);
	if(result == 1)
	{
		for(i=0;i<wnum;i++)
		{
		  if((WLANINFO)&&(WLANINFO->WLAN[i])&&(WLANINFO->WLAN[i]->WlanID==wlan_id))
			fprintf(cgiOut,"<option value=%d selected=selected>%d",WLANINFO->WLAN[i]->WlanID,WLANINFO->WLAN[i]->WlanID);
		  else
			fprintf(cgiOut,"<option value=%d>%d",WLANINFO->WLAN[i]->WlanID,WLANINFO->WLAN[i]->WlanID);
		}
	}
    fprintf(cgiOut,"</select></td>"\
    "<td width=150>&nbsp;</td>"\
  "</tr>"\
  "<tr height=30>"\
    "<td>%s:</td>",search(lwlan,"type"));
    fprintf(cgiOut,"<td align=left><select name=wlan_type id=wlan_type style=width:80px onchange=\"javascript:this.form.submit();\">");
	for(i=0;i<3;i++)
    if(strcmp(mac_policy[i],n)==0)              /*显示上次选中的mac policy*/
      fprintf(cgiOut,"<option value=%s selected=selected>%s",mac_policy[i],mac_policy[i]);
    else			  	
	  fprintf(cgiOut,"<option value=%s>%s",mac_policy[i],mac_policy[i]);
	fprintf(cgiOut,"</select></td>"\
    "<td >&nbsp;</td>"\
  "</tr>"\
  "<tr height=30>"\
    "<td>MAC:</td>"\
    "<td align=left>");
	cgiFormSelectSingle("wlan_type", mac_policy, 3, &macPolicyChoice, 0);
    if(macPolicyChoice==0)
      fprintf(cgiOut,"<input type=text name=wlan_mac disabled=\"disabled\">");
	else
	  fprintf(cgiOut,"<input type=text name=wlan_mac maxLength=17 onkeypress=\"return event.keyCode!=32\">");
	fprintf(cgiOut,"</td>");
      fprintf(cgiOut,"<td align=left><font color=red>%s</font></td>",search(lpublic,"mac_format"));
  fprintf(cgiOut,"</tr>"\
  "<tr>"\
    "<td><input type=hidden name=encry_newwlan value=%s></td>",m);
    fprintf(cgiOut,"<td colspan=2><input type=hidden name=INSTANCE_ID value=%s></td>",select_insid);
  fprintf(cgiOut,"</tr>"\
"</table>"\
              "</td>"\
            "</tr>"\
            "<tr height=4 valign=top>"\
              "<td width=120 height=4 align=right valign=top><img src=/images/bottom_07.gif width=1 height=10/></td>"\
              "<td width=827 height=4 valign=top bgcolor=#FFFFFF><img src=/images/bottom_06.gif width=827 height=15/></td>"\
            "</tr>"\
          "</table>"\
        "</td>"\
        "<td width=15 background=/images/di999.jpg>&nbsp;</td>"\
      "</tr>"\
    "</table></td>"\
  "</tr>"\
  "<tr>"\
    "<td colspan=3 align=left valign=top background=/images/di777.jpg><img src=/images/di555.jpg width=61 height=62/></td>"\
    "<td align=left valign=top background=/images/di777.jpg>&nbsp;</td>"\
    "<td align=left valign=top background=/images/di777.jpg><img src=/images/di666.jpg width=74 height=62/></td>"\
  "</tr>"\
"</table>"\
"</div>"\
"</form>"\
"</body>"\
"</html>");
if(result == 1)
{
  Free_wlan_head(WLANINFO);
}
free_instance_parameter_list(&paraHead1);
return 0;
}