/* * Count the number of arguments other than * extURL, extMethod, and extCallback. */ int countArguments(void) { int count = 0; char **array, **arrayStep; if(cgiFormEntries(&array) != cgiFormSuccess) { return 0; } arrayStep = array; while(*arrayStep) { arrayStep++; count++; } cgiStringArrayFree(array); //subtract 'api' variables if(strstr(cgiQueryString,URL_PARAM_NAME)) count--; if(strstr(cgiQueryString,CALLBACK_PARAM_NAME)) count--; return count; }
void NonExButtons() { int voteChoices[4]; int i; int result; int invalid; char **responses; /* Method #1: check for valid votes. This is a good idea, since votes for nonexistent candidates should probably be discounted... */ fprintf(cgiOut, "Votes (method 1):<BR>\n"); result = cgiFormCheckboxMultiple("vote", votes, 4, voteChoices, &invalid); if (result == cgiFormNotFound) { fprintf(cgiOut, "I hate them all!<p>\n"); } else { fprintf(cgiOut, "My preferred candidates are:\n"); fprintf(cgiOut, "<ul>\n"); for (i=0; (i < 4); i++) { if (voteChoices[i]) { fprintf(cgiOut, "<li>%s\n", votes[i]); } } fprintf(cgiOut, "</ul>\n"); } /* Method #2: get all the names voted for and trust them. This is good if the form will change more often than the code and invented responses are not a danger or can be checked in some other way. */ fprintf(cgiOut, "Votes (method 2):<BR>\n"); result = cgiFormStringMultiple("vote", &responses); if (result == cgiFormNotFound) { fprintf(cgiOut, "I hate them all!<p>\n"); } else { int i = 0; fprintf(cgiOut, "My preferred candidates are:\n"); fprintf(cgiOut, "<ul>\n"); while (responses[i]) { fprintf(cgiOut, "<li>%s\n", responses[i]); i++; } fprintf(cgiOut, "</ul>\n"); } /* We must be sure to free the string array or a memory leak will occur. Simply calling free() would free the array but not the individual strings. The function cgiStringArrayFree() does the job completely. */ cgiStringArrayFree(responses); }
void deleteuser_hand(struct list *lpublic, struct list *lsystem) { int result; char **responses; int ret,status; int count = 0; /*记录删除成功的个数*/ result = cgiFormStringMultiple("check", &responses); if(result == cgiFormNotFound) /*如果没有选择任何用户*/ ShowAlert(search(lsystem,"select_user")); else { int i = 0; while(responses[i]) { char *command = (char*)malloc(PATH_LENG); /*command存放命令行参数*/ memset(command,0,PATH_LENG); strcat(command,"userdel.sh"); strcat(command," "); strcat(command,responses[i]); status = system(command); /*删除用户*/ ret = WEXITSTATUS(status); if(ret==0) { count++; } free(command); i++; } if(count) { ShowAlert(search(lpublic,"oper_succ")); } else { ShowAlert(search(lpublic,"oper_fail")); } cgiStringArrayFree(responses); } }
void Entries() { char **array, **arrayStep; fprintf(cgiOut, "List of All Submitted Form Field Names:<p>\n"); if (cgiFormEntries(&array) != cgiFormSuccess) { return; } arrayStep = array; fprintf(cgiOut, "<ul>\n"); while (*arrayStep) { fprintf(cgiOut, "<li>"); cgiHtmlEscape(*arrayStep); fprintf(cgiOut, "\n"); arrayStep++; } fprintf(cgiOut, "</ul>\n"); cgiStringArrayFree(array); }
/* * Iterate through the passed name=value pairs * and construct extArg structs for each of them. * * Add them to the array of extArg structs inside * the req struct */ int parseArguments(struct extRequest *req) { char **array, **arrayStep; if (cgiFormEntries(&array) != cgiFormSuccess) { return 0; } int num_args = countArguments(); int arg_num = 0; req->numargs = num_args; /* make req->args big enough to hold all the extArg structs */ req->args = (struct extArg **)malloc(sizeof(struct extArg)*num_args); arrayStep = array; int val_size = 0; char *val; while (*arrayStep) { /* If the name is not a URL, method, or callback, we need to add it */ if(strcmp(*arrayStep, URL_PARAM_NAME) != 0 && strcmp(*arrayStep, CALLBACK_PARAM_NAME) != 0) { /* Get the length of the passed string so our buffer is big enough. */ cgiFormStringSpaceNeeded(*arrayStep, &val_size); val = (char*)malloc(sizeof(char)*val_size); cgiFormString(*arrayStep, val, val_size); req->args[arg_num++] = makeArg(*arrayStep, val); /* The val has been passed to makeArg, so free it */ free(val); } arrayStep++; } cgiStringArrayFree(array); return 1; }
void Cookies() { char **array, **arrayStep; char cname[1024], cvalue[1024]; fprintf(cgiOut, "Cookies Submitted On This Call, With Values (Many Browsers NEVER Submit Cookies):<p>\n"); if (cgiCookies(&array) != cgiFormSuccess) { return; } arrayStep = array; fprintf(cgiOut, "<table border=1>\n"); fprintf(cgiOut, "<tr><th>Cookie<th>Value</tr>\n"); while (*arrayStep) { char value[1024]; fprintf(cgiOut, "<tr>"); fprintf(cgiOut, "<td>"); cgiHtmlEscape(*arrayStep); fprintf(cgiOut, "<td>"); cgiCookieString(*arrayStep, value, sizeof(value)); cgiHtmlEscape(value); fprintf(cgiOut, "\n"); arrayStep++; } fprintf(cgiOut, "</table>\n"); cgiFormString("cname", cname, sizeof(cname)); cgiFormString("cvalue", cvalue, sizeof(cvalue)); if (strlen(cname)) { fprintf(cgiOut, "New Cookie Set On This Call:<p>\n"); fprintf(cgiOut, "Name: "); cgiHtmlEscape(cname); fprintf(cgiOut, "Value: "); cgiHtmlEscape(cvalue); fprintf(cgiOut, "<p>\n"); fprintf(cgiOut, "If your browser accepts cookies (many do not), this new cookie should appear in the above list the next time the form is submitted.<p>\n"); } cgiStringArrayFree(array); }
int ShowLogconfPage(struct list *lcontrol,struct list *lpublic) { char *encry=(char *)malloc(BUF_LEN); char *str; char deb[128]; memset(deb,0,128); char file_name[128]; //读取文件 memset(file_name,0,128); char zstring[128]; //父串 memset(zstring,0,128); char subs[128]; //子串 memset(subs,0,128); char log_encry[BUF_LEN]; int ret ; /*命令及命令执行结果*/ int op_ret; int j = 0; int i=-1; int ir=0; int flag=1; /*标志这状态*/ char showtype[N]; memset(showtype,0,N); char dstring[128]; /*插入的规则行内容*/ memset(dstring,0,128); char dstring1[128]; /*插入的规则行内容*/ memset(dstring1,0,128); char dstring2[128]; /*插入的规则行内容*/ memset(dstring2,0,128); char dstring3[128]; /*插入的规则行内容*/ memset(dstring3,0,128); char tcpname[N]; /*下拉框内容*/ memset(tcpname,0,N); ST_SYS_ALL sysall; /*总的结构体内容*/ memset(&sysall,0,sizeof(sysall)); ST_LOG_KEY logkey; memset(&logkey,0,sizeof(logkey)); char *fpath; fpath=XML_FPATH; /*要修改的内容*/ char content[128]; memset(content,0,128); cgiFormStringNoNewlines("Nb", file_name, 128); if(cgiFormSubmitClicked("version") != cgiFormSuccess) { memset(encry,0,BUF_LEN); cgiFormStringNoNewlines("UN", encry, BUF_LEN); str=dcryption(encry); if(str==NULL) { ShowErrorPage(search(lpublic,"ill_user")); /*用户非法*/ } memset(log_encry,0,BUF_LEN); /*清空临时变量*/ } else { cgiFormStringNoNewlines("encry_version", log_encry, BUF_LEN); str=dcryption(log_encry); if(str==NULL) { ShowErrorPage(search(lpublic,"ill_user")); /*用户非法*/ } memset(log_encry,0,BUF_LEN); /*清空临时变量*/ } cgiFormStringNoNewlines("encry_version",log_encry,BUF_LEN); 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,"<link rel=stylesheet href=/style.css type=text/css>"\ "<style type=text/css>"\ ".a3{width:30;border:0; text-align:center}"\ "</style>"\ "</head>"\ "<script language=javascript src=/ip.js>"\ "</script>"\ "<script type='text/javascript'>"\ "function changestate(){"\ "var fl = document.getElementsByName('showtype')[0];"\ "var tcd = document.getElementsByName('showtype')[1];"\ "var user = document.getElementsByName('showtype')[2];"\ "}"\ "</script>"\ "<body>"); /*----------------------------begin-----------------------------------------------*/ /* $1 : 传过来的目的规则名 $2 : syslog 文件 $3 : 临时文件名 $4 : 添加的新规则名 */ /* 重启服务*/ if(cgiFormSubmitClicked("reboot") == cgiFormSuccess) { int ret; ret=restart_syslog(); if(ret==0) ShowAlert(search(lpublic,"oper_succ")); else ShowAlert(search(lpublic,"oper_fail")); } /*恢复默认,删除旧有文件并重新生成新文件,先删除xml文件,读取信息是从xml来的*/ if(cgiFormSubmitClicked("default") == cgiFormSuccess) { sprintf(deb,"sudo rm %s",XML_FPATH); ret=system(deb); memset(deb,0,128); sprintf(deb,"sudo rm %s",CONF_FPATH); op_ret=system(deb); restart_syslog(); if(ret==0 && op_ret==0) ShowAlert(search(lpublic,"oper_succ")); else ShowAlert(search(lpublic,"oper_fail")); } /*保存更改 此页面主要是修改log 信息的,其他配置另有页面*/ if(cgiFormSubmitClicked("submit_mod") == cgiFormSuccess) { cgiFormStringNoNewlines("showtype", showtype, N); int result; char **responses; result = cgiFormStringMultiple("showtype", &responses); //多选框的操作 if((strcmp(showtype,"1")!=0)&&(strcmp(showtype,"3")!=0)&&(strcmp(showtype,"2")!=0)) { ShowAlert(search(lpublic,"log_no_opt")); } else{ i = 0; while(responses[i]) { i++; } /*只选 1,3 的双选情况 修改的是log的 content 信息,这样相对conf比较稳定,要找到value的关键字 */ if(i==2 && (strcmp(responses[0],"1")==0)&&(strcmp(responses[1],"3")==0)) { char temp[60]; memset(temp,0,60); ir=find_log_node(fpath,NODE_DES,NODE_ATT,file_name,NODE_VALUE,&logkey); sprintf(dstring1,"%s;",logkey.key); memset(&logkey,0,sizeof(logkey)); ir=find_log_node(fpath,NODE_DES,NODE_ATT,L_ALL,NODE_VALUE,&logkey); sprintf(temp,"%s;",logkey.key); strcat(dstring1,temp); //fprintf(cgiOut,"zone: %s",dstring1); mod_log_node(fpath, NODE_LOG, NODE_ATT,file_name, CH_DEST,dstring1); read_filter(fpath, NODE_LOG, &sysall); ret=write_config(&sysall,CONF_FPATH); if(ret==0) ShowAlert(search(lpublic,"oper_succ")); else ShowAlert(search(lpublic,"oper_fail")); } //只选 1,2 的双选情况 if(i==2 && (strcmp(responses[0],"1")==0)&&(strcmp(responses[1],"2")==0)) { char temp[60]; memset(temp,0,60); ir=find_log_node(fpath,NODE_DES,NODE_ATT,file_name,NODE_VALUE,&logkey); sprintf(dstring1,"%s;",logkey.key); //fprintf(cgiOut,"fen: %s<br>",dstring1); memset(&logkey,0,sizeof(logkey)); ir=find_log_node(fpath,NODE_DES,NODE_ATT,L_IP,NODE_VALUE,&logkey); sprintf(temp,"%s;",logkey.key); strcat(dstring1,temp); //fprintf(cgiOut,"zone: %s<br>",dstring1); mod_log_node(fpath, NODE_LOG, NODE_ATT, file_name, CH_DEST,dstring1); read_filter(fpath, NODE_LOG, &sysall); ret=write_config(&sysall,CONF_FPATH); if(ret==0) ShowAlert(search(lpublic,"oper_succ")); else ShowAlert(search(lpublic,"oper_fail")); } //只选 2,3 的双选情况 if(i==2 && (strcmp(responses[0],"2")==0)&&(strcmp(responses[1],"3")==0)) { char temp[60]; memset(temp,0,60); ir=find_log_node(fpath,NODE_DES,NODE_ATT,L_IP,NODE_VALUE,&logkey); sprintf(dstring1,"%s;",logkey.key); //fprintf(cgiOut,"fen: %s<br>",dstring1); memset(&logkey,0,sizeof(logkey)); ir=find_log_node(fpath,NODE_DES,NODE_ATT,L_ALL,NODE_VALUE,&logkey); sprintf(temp,"%s;",logkey.key); strcat(dstring1,temp); //fprintf(cgiOut,"zone: %s<br>",dstring1); mod_log_node(fpath, NODE_LOG, NODE_ATT, file_name, CH_DEST,dstring1); read_filter(fpath, NODE_LOG, &sysall); ret=write_config(&sysall,CONF_FPATH); if(ret==0) ShowAlert(search(lpublic,"oper_succ")); else ShowAlert(search(lpublic,"oper_fail")); } //三个框都选的情况 if(i==3 && (strcmp(responses[0],"1")==0)&&(strcmp(responses[1],"2")==0)&&(strcmp(responses[2],"3")==0)) { char temp[60]; memset(temp,0,60); ir=find_log_node(fpath,NODE_DES,NODE_ATT,file_name,NODE_VALUE,&logkey); sprintf(dstring1,"%s;",logkey.key); // fprintf(cgiOut,"fen: %s<br>",dstring1); memset(&logkey,0,sizeof(logkey)); ir=find_log_node(fpath,NODE_DES,NODE_ATT,L_IP,NODE_VALUE,&logkey); sprintf(temp,"%s;",logkey.key); strcat(dstring1,temp); memset(&logkey,0,sizeof(logkey)); memset(temp,0,60); ir=find_log_node(fpath,NODE_DES,NODE_ATT,L_ALL,NODE_VALUE,&logkey); sprintf(temp,"%s;",logkey.key); strcat(dstring1,temp); //fprintf(cgiOut,"zone: %s",dstring1); mod_log_node(fpath, NODE_LOG, NODE_ATT,file_name, CH_DEST,dstring1); read_filter(fpath, NODE_LOG, &sysall); ret=write_config(&sysall,CONF_FPATH); if(ret==0) ShowAlert(search(lpublic,"oper_succ")); else ShowAlert(search(lpublic,"oper_fail")); } /*单选一 */ if(i==1 && (strcmp(responses[0],"1")==0)) { memset(dstring1,0,128); ir=find_log_node(fpath,NODE_DES,NODE_ATT,file_name,NODE_VALUE,&logkey); sprintf(dstring1,"%s;",logkey.key); // fprintf(cgiOut,"fen: %s<br>",dstring1); mod_log_node(fpath, NODE_LOG, NODE_ATT, file_name, CH_DEST,dstring1); read_filter(fpath, NODE_LOG, &sysall); // fprintf(cgiOut,"test: %d<br>",sysall.des_num); ret=write_config(&sysall,CONF_FPATH); if(ret==0) ShowAlert(search(lpublic,"oper_succ")); else ShowAlert(search(lpublic,"oper_fail")); } //单选二 if(i==1 && (strcmp(responses[0],"2")==0)) { ir=find_log_node(fpath,NODE_DES,NODE_ATT,L_IP,NODE_VALUE,&logkey); sprintf(dstring1,"%s;",logkey.key); // fprintf(cgiOut,"fen: %s<br>",dstring1); mod_log_node(fpath, NODE_LOG, NODE_ATT, file_name, CH_DEST,dstring1); read_filter(fpath, NODE_LOG, &sysall); ret=write_config(&sysall,CONF_FPATH); if(ret==0) ShowAlert(search(lpublic,"oper_succ")); else ShowAlert(search(lpublic,"oper_fail")); } //单选三 if(i==1 && (strcmp(responses[0],"3")==0)) { ir=find_log_node(fpath,NODE_DES,NODE_ATT,L_ALL,NODE_VALUE,&logkey); sprintf(dstring1,"%s;",logkey.key); // fprintf(cgiOut,"fen: %s<br>",dstring1); mod_log_node(fpath, NODE_LOG, NODE_ATT, file_name, CH_DEST,dstring1); read_filter(fpath, NODE_LOG, &sysall); ret=write_config(&sysall,CONF_FPATH); // fprintf(cgiOut,"<br>ir: %d",ret); if(ret==0) ShowAlert(search(lpublic,"oper_succ")); else ShowAlert(search(lpublic,"oper_fail")); } } cgiStringArrayFree(responses); } /*----------------------------- end ----------------------------------------------*/ fprintf(cgiOut,"<form method=post encType=multipart/form-data>"\ "<div align=center>"\ "<table width=976 border=0 cellpadding=0 cellspacing=0>"); //111111111111111111111 fprintf(cgiOut,"<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(lpublic,"log_info")); fprintf(cgiOut,"<td width=690 align=right valign=bottom background=/images/di22.jpg>"); // 鉴权 fprintf(cgiOut,"<input type=hidden name=UN value=%s />",encry); fprintf(cgiOut,"<input type=hidden name=Nb value=%s />",file_name); //取到传送的值 fprintf(cgiOut,"<table width=130 border=0 cellspacing=0 cellpadding=0>"\ "<tr>"\ "<td width=62 align=center><input id=but type=submit name=submit_mod style=background-image:url(/images/%s) value=""></td>",search(lpublic,"img_ok")); if(cgiFormSubmitClicked("submit_mod") != cgiFormSuccess) fprintf(cgiOut,"<td width=62 align=left><a href=wp_log_info.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_log_info.cgi?UN=%s target=mainFrame><img src=/images/%s border=0 width=62 height=20/></a></td>",log_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>"); fprintf(cgiOut,"<td colspan=5 align=center valign=middle><table width=976 border=0 cellpadding=0 cellspacing=0 bgcolor=#f0eff0>"); //333333333333333333333 fprintf(cgiOut,"<tr>"); fprintf(cgiOut,"<td width=12 align=left valign=top background=/images/di888.jpg> </td>"\ "<td width=948><table width=947 border=0 cellspacing=0 cellpadding=0>"); //44444444444444444444 fprintf(cgiOut,"<tr height=4 valign=bottom>"\ "<td width=120> </td>"\ "<td width=827 valign=bottom><img src=/images/bottom_05.gif width=827 height=4/></td>"\ "</tr>"); fprintf(cgiOut,"<tr>"); //次内 fprintf(cgiOut,"<td><table width=120 border=0 cellspacing=0 cellpadding=0>"); //555555555555555 fprintf(cgiOut,"<tr height=25>"\ "<td id=tdleft> </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(lpublic,"log_modrule")); /*突出显示*/ fprintf(cgiOut,"</tr>"); fprintf(cgiOut,"<tr height=25>"\ "<td align=left id=tdleft><a href=wp_log_add.cgi?UN=%s&Nb=%s target=mainFrame class=top><font id=%s>%s</font></a></td>",encry,file_name,search(lpublic,"menu_san"),search(lpublic,"log_addip")); fprintf(cgiOut,"</tr>"); for(j=0;j<13;j++) { fprintf(cgiOut,"<tr height=25>"\ "<td id=tdleft> </td>"\ "</tr>"); } fprintf(cgiOut,"</table>"); //555555555555555555555 fprintf(cgiOut,"</td>"\ "<td align=left valign=top style=\"background-color:#ffffff; border-right:1px solid #707070; padding-left:30px; padding-top:10px\">"); fprintf(cgiOut,"<table width=460 border=0 cellspacing=0 cellpadding=0>"); //66666666666666666 fprintf(cgiOut,"<tr>"); //内 fprintf(cgiOut,"<td colspan=2 style=\"padding-top:20px\">"); fprintf(cgiOut,"<table width=460 border=0 bordercolor=#cccccc cellspacing=0 cellpadding=0>"); //777777777777777777777 memset(showtype,0,N); cgiFormStringNoNewlines("showtype", showtype, N); fprintf(cgiOut,"<tr><td>"); fprintf(cgiOut,"<input type=submit name=reboot value=\"%s\">",search(lpublic,"log_reboot")); fprintf(cgiOut,"<input type=submit name=default value=\"%s\"></td>",search(lpublic,"log_def")); fprintf(cgiOut,"</tr>"); fprintf(cgiOut,"<tr height=12><td></td></tr>"); fprintf(cgiOut,"<tr><td>"); fprintf(cgiOut, "<div class=\"col1\"> \n" ); fprintf(cgiOut, "<label class=\"col1\"> \n" ); fprintf(cgiOut, "<h4>%s</h4> \n", search(lpublic,"log_dest") ); fprintf(cgiOut, "</label> \n" ); fprintf(cgiOut, "</div> \n" ); fprintf(cgiOut,"</td></tr>"); fprintf(cgiOut, "<tr><td><hr width=100%% size=1 color=#fff align=center noshade /></td><td>"\ "<hr width=100%% size=1 color=#fff align=center noshade /></td><td>"\ "<hr width=100%% size=1 color=#fff align=center noshade /></td>"\ "</tr>" ); fprintf(cgiOut,"<tr height=12><td></td></tr>"); fprintf(cgiOut,"<tr ><td>"); find_log_node(fpath,NODE_LOG,NODE_ATT,file_name,CH_DEST,&logkey); //log的dest属性 strcpy(zstring,logkey.key); find_log_node(fpath,NODE_DES,NODE_ATT,file_name,NODE_VALUE,&logkey); strcpy(subs,logkey.key); flag=if_subs(zstring,subs); if(flag==2) fprintf(cgiOut, "<input type=\"checkbox\" name=\"showtype\" value=\"1\" onclick=\"changestate()\" checked ></td><td>\n" ); else fprintf(cgiOut, "<input type=\"checkbox\" name=\"showtype\" value=\"1\" onclick=\"changestate()\" ></td><td>\n" ); fprintf(cgiOut, "<label class=\"col1\" for=\"Package.DestinationAddress.Single\">%s</label></td><td> \n", search(lpublic,"log_file")); fprintf(cgiOut,"</td></tr>"); fprintf(cgiOut,"<tr height=12><td></td></tr>"); //分割线 fprintf(cgiOut, "<tr><td><hr width=100%% size=1 color=#fff align=center noshade /></td><td>"\ "<hr width=100%% size=1 color=#fff align=center noshade /></td><td>"\ "<hr width=100%% size=1 color=#fff align=center noshade /></td>"\ "</tr>" ); fprintf(cgiOut,"<tr height=12><td></td></tr>"); fprintf(cgiOut,"<tr ><td>"); find_log_node(fpath,NODE_DES,NODE_ATT,L_IP,NODE_VALUE,&logkey); strcpy(subs,logkey.key); flag=if_subs(zstring,subs); if(flag==2) fprintf(cgiOut, "<input type=\"checkbox\" name=\"showtype\" value=\"2\" onclick=\"changestate()\" checked ></td><td>\n" ); else fprintf(cgiOut, "<input type=\"checkbox\" name=\"showtype\" value=\"2\" onclick=\"changestate()\" ></td><td>\n" ); fprintf(cgiOut, "<label class=\"col1\" for=\"Package.DestinationAddress.Single\">%s</label></td><td> \n", search(lpublic,"log_port")); fprintf(cgiOut,"</td>"); fprintf(cgiOut,"</tr>"); fprintf(cgiOut,"<tr height=7><td></td></tr>"); fprintf(cgiOut,"<tr><td></td>"); fprintf(cgiOut,"<td><a href=wp_log_add.cgi?UN=%s&Nb=%s><font color=blue size=2>%s</font></a></td></tr>",encry,file_name,search(lpublic,"log_addip")); //分割线 fprintf(cgiOut, "<tr><td><hr width=100%% size=1 color=#fff align=center noshade /></td><td>"\ "<hr width=100%% size=1 color=#fff align=center noshade /></td><td>"\ "<hr width=100%% size=1 color=#fff align=center noshade /></td>"\ "</tr>" ); fprintf(cgiOut,"<tr height=12><td></td></tr>"); fprintf(cgiOut,"<tr ><td bgcolor=#FFFFFF>"); find_log_node(fpath,NODE_DES,NODE_ATT,L_ALL,NODE_VALUE,&logkey); strcpy(subs,logkey.key); flag=if_subs(zstring,subs); if(flag==2) fprintf(cgiOut, "<input type=\"checkbox\" name=\"showtype\" value=\"3\" onclick=\"changestate()\" checked></td><td>\n" ); else fprintf(cgiOut, "<input type=\"checkbox\" name=\"showtype\" value=\"3\" onclick=\"changestate()\" ></td><td>\n" ); fprintf(cgiOut, "<label class=\"col1\" for=\"Package.DestinationAddress.Single\">%s</label></td> \n", search(lpublic,"log_user") ); fprintf(cgiOut,"</tr>"); fprintf(cgiOut,"<tr height=12><td></td></tr>"); //分割线 fprintf(cgiOut, "<tr><td><hr width=100%% size=1 color=#fff align=center noshade /></td><td>"\ "<hr width=100%% size=1 color=#fff align=center noshade /></td><td>"\ "<hr width=100%% size=1 color=#fff align=center noshade /></td>"\ "</tr>" ); fprintf(cgiOut,"<tr height=12><td></td></tr>"); if(cgiFormSubmitClicked("submit_mod") != cgiFormSuccess) { fprintf(cgiOut,"<td><input type=hidden name=fdb_encry value=%s></td>",encry); } else if(cgiFormSubmitClicked("submit_mod") == cgiFormSuccess) { fprintf(cgiOut,"<td><input type=hidden name=fdb_encry value=%s></td>",log_encry); } fprintf(cgiOut,"</table>"); //7777777777777777777 fprintf(cgiOut,"</td></tr>"); fprintf(cgiOut,"<tr>"); if(cgiFormSubmitClicked("version") != cgiFormSuccess) { fprintf(cgiOut,"<td><input type=hidden name=encry_version value=%s></td>",encry); } else if(cgiFormSubmitClicked("version") == cgiFormSuccess) { fprintf(cgiOut,"<td><input type=hidden name=encry_version value=%s></td>",log_encry); } fprintf(cgiOut,"</tr>"\ "</table>"); //6666666666666666666 fprintf(cgiOut,"</td>"); fprintf(cgiOut,"</tr>"); //内 fprintf(cgiOut,"<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>"); //444444444444444444444 fprintf(cgiOut,"</td>"\ "<td width=15 background=/images/di999.jpg> </td>"); fprintf(cgiOut,"</tr>"); //次内 fprintf(cgiOut,"</table></td>"); //33333333333333333333 fprintf(cgiOut,"</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> </td>"\ "<td align=left valign=top background=/images/di777.jpg><img src=/images/di666.jpg width=74 height=62/></td>"\ "</tr>"\ "</table>"); //1111111111111111111 fprintf(cgiOut,"</div>"\ "</form>"\ "</body>"); fprintf(cgiOut,"</html>"); free(encry); return 0; }
void config_ebr(instance_parameter *ins_para,int id,struct list *lpublic,struct list *lwlan) /*返回0表示失败,返回1表示成功*/ { int flag = 1,ret = 0; int result = cgiFormNotFound,i = 0,bind_result = 0; char **responses; char state[20] = { 0 }; char temp[100] = { 0 }; char ebr_id[10] = { 0 }; /***********************config ethereal bridge enable**************************/ memset(state,0,sizeof(state)); cgiFormStringNoNewlines("ebr_use",state,20); if(strcmp(state,"")!=0) { ret=config_ethereal_bridge_enable_cmd(ins_para->parameter,ins_para->connection,id,state); /*返回0表示失败,返回1表示成功,返回-1表示input parameter should only be 'enable' or 'disable'*/ /*返回-2表示ebr id does not exist,返回-3表示ebr if error,返回-4表示system cmd process error,返回-5表示error*/ switch(ret) { case SNMPD_CONNECTION_ERROR: case 0:ShowAlert(search(lwlan,"con_ebr_state_fail")); flag=0; break; case 1:break; case -1:ShowAlert(search(lpublic,"input_para_error")); flag=0; break; case -2:ShowAlert(search(lwlan,"ebr_not_exist")); flag=0; break; case -3:ShowAlert(search(lwlan,"ebr_if_error")); flag=0; break; case -4:ShowAlert(search(lpublic,"sys_cmd_error")); flag=0; break; case -5:ShowAlert(search(lpublic,"error")); flag=0; break; } } /***********************set ebr add if cmd**************************/ result = cgiFormStringMultiple("bind_interface", &responses); if(result != cgiFormNotFound) { i = 0; bind_result=1; while((responses[i])&&(bind_result==1)) { ret=set_ebr_add_del_if_cmd(ins_para->parameter,ins_para->connection,id,"add",responses[i]); /*返回0表示失败,返回1表示成功,返回-1表示input parameter should only be 'add' or 'delete'*/ /*返回-2表示if name too long,返回-3表示ebr id does not exist,返回-4表示ebr should be disable first*/ /*返回-5表示if_name already exist/remove some br,or system cmd process error,返回-6表示input ifname error*/ /*返回-7表示ebr if error,返回-8表示error,返回-9示EBR ID非法*/ /*返回-10表示you want to delete wlan, please do not operate like this*/ /*返回-11表示please check the interface's wlanid, you maybe have delete this wlan*/ switch(ret) { case SNMPD_CONNECTION_ERROR: case 0:ShowAlert(search(lwlan,"bind_interface_fail")); bind_result=0; break; case 1:break; case -1:ShowAlert(search(lpublic,"input_para_error")); bind_result=0; break; case -2:ShowAlert(search(lpublic,"if_name_long")); bind_result=0; break; case -3:ShowAlert(search(lwlan,"ebr_not_exist")); bind_result=0; break; case -4:ShowAlert(search(lwlan,"dis_ebr")); bind_result=0; break; case -5:ShowAlert(search(lwlan,"if_name_exist")); bind_result=0; break; case -6:ShowAlert(search(lpublic,"input_ifname_error")); bind_result=0; break; case -7:ShowAlert(search(lwlan,"ebr_if_error")); bind_result=0; break; case -8:ShowAlert(search(lpublic,"error")); bind_result=0; break; case -9:{ memset(temp,0,sizeof(temp)); strncpy(temp,search(lwlan,"ebr_id_1"),sizeof(temp)-1); memset(ebr_id,0,sizeof(ebr_id)); snprintf(ebr_id,sizeof(ebr_id)-1,"%d",EBR_NUM-1); strncat(temp,ebr_id,sizeof(temp)-strlen(temp)-1); strncat(temp,search(lwlan,"ebr_id_2"),sizeof(temp)-strlen(temp)-1); ShowAlert(temp); bind_result=0; break; } case -10:ShowAlert(search(lwlan,"dont_del_wlan")); bind_result=0; break; case -11:ShowAlert(search(lwlan,"have_del_wlan")); bind_result=0; break; } i++; } cgiStringArrayFree(responses); if(bind_result==0) flag = 0; } /***********************set ebr add uplink cmd**************************/ result = cgiFormStringMultiple("set_uplink_interface", &responses); if(result != cgiFormNotFound) { i = 0; bind_result=1; while((responses[i])&&(bind_result==1)) { ret=set_ebr_add_del_uplink_cmd(ins_para->parameter,ins_para->connection,id,"add",responses[i]); /*返回0表示失败,返回1表示成功,返回-1表示error*/ /*返回-2表示input parameter should only be 'add' or 'delete',返回-3表示if name too long*/ /*返回-4表示malloc error,返回-5表示ebr should be disable first*/ /*返回-6表示already exist/remove some br,or system cmd process error,返回-7表示input ifname error*/ /*返回-8表示ebr if error,返回-9表示interface does not add to br or br uplink,返回-10表示ebr id does not exist*/ /*返回-11示EBR ID非法*/ switch(ret) { case SNMPD_CONNECTION_ERROR: case 0:ShowAlert(search(lwlan,"set_uplink_interface_fail")); bind_result=0; break; case 1:break; case -1:ShowAlert(search(lpublic,"error")); bind_result=0; break; case -2:ShowAlert(search(lpublic,"input_para_error")); bind_result=0; break; case -3:ShowAlert(search(lpublic,"if_name_long")); bind_result=0; break; case -4:ShowAlert(search(lpublic,"malloc_error")); bind_result=0; break; case -5:ShowAlert(search(lwlan,"dis_ebr")); bind_result=0; break; case -6:ShowAlert(search(lwlan,"if_name_exist")); bind_result=0; break; case -7:ShowAlert(search(lpublic,"input_ifname_error")); bind_result=0; break; case -8:ShowAlert(search(lwlan,"ebr_if_error")); bind_result=0; break; case -9:ShowAlert(search(lwlan,"if_not_add_to_br")); bind_result=0; break; case -10:ShowAlert(search(lwlan,"ebr_not_exist")); bind_result=0; break; case -11:{ memset(temp,0,sizeof(temp)); strncpy(temp,search(lwlan,"ebr_id_1"),sizeof(temp)-1); memset(ebr_id,0,sizeof(ebr_id)); snprintf(ebr_id,sizeof(ebr_id)-1,"%d",EBR_NUM-1); strncat(temp,ebr_id,sizeof(temp)-strlen(temp)-1); strncat(temp,search(lwlan,"ebr_id_2"),sizeof(temp)-strlen(temp)-1); ShowAlert(temp); bind_result=0; break; } } i++; } cgiStringArrayFree(responses); if(bind_result==0) flag = 0; } /***********************ebr set bridge isolation func**************************/ memset(state,0,sizeof(state)); cgiFormStringNoNewlines("iso_use",state,20); if(strcmp(state,"")!=0) { ret=ebr_set_bridge_isolation_func(ins_para->parameter,ins_para->connection,id,state); /*返回0表示失败,返回1表示成功,返回-1表示input parameter should only be 'enable' or 'disable'*/ /*返回-2表示ebr id does not exist,返回-3表示ebr should be disable first,返回-4表示ebr if error*/ /*返回-5表示system cmd process error,返回-6表示sameportswitch and isolation are conflict,disable sameportswitch first*/ /*返回-7表示error,返回-8示EBR ID非法,返回-9表示apply security in this wlan first*/ switch(ret) { case SNMPD_CONNECTION_ERROR: case 0:ShowAlert(search(lwlan,"con_ebr_isolate_fail")); flag=0; break; case 1:break; case -1:ShowAlert(search(lpublic,"input_para_error")); flag=0; break; case -2:ShowAlert(search(lwlan,"ebr_not_exist")); flag=0; break; case -3:ShowAlert(search(lwlan,"dis_ebr")); flag=0; break; case -4:ShowAlert(search(lwlan,"ebr_if_error")); flag=0; break; case -5:ShowAlert(search(lpublic,"sys_cmd_error")); flag=0; break; case -6:ShowAlert(search(lwlan,"spswi_iso_conflict")); flag=0; break; case -7:ShowAlert(search(lpublic,"error")); flag=0; break; case -8:{ memset(temp,0,100); strcpy(temp,search(lwlan,"ebr_id_1")); memset(ebr_id,0,10); sprintf(ebr_id,"%d",EBR_NUM-1); strcat(temp,ebr_id); strcat(temp,search(lwlan,"ebr_id_2")); ShowAlert(temp); flag=0; break; } case -9:ShowAlert(search(lwlan,"con_bind")); flag=0; break; } } /***********************ebr set bridge multicast isolation func**************************/ memset(state,0,sizeof(state)); cgiFormStringNoNewlines("mult_use",state,20); if(strcmp(state,"")!=0) { ret=ebr_set_bridge_multicast_isolation_func(ins_para->parameter,ins_para->connection,id,state); /*返回0表示失败,返回1表示成功,返回-1表示input parameter should only be 'enable' or 'disable'*/ /*返回-2表示ebr id does not exist,返回-3表示ebr should be disable first,返回-4表示ebr if error*/ /*返回-5表示system cmd process error,返回-6表示sameportswitch and isolation are conflict,disable sameportswitch first*/ /*返回-7表示error,返回-8示EBR ID非法,返回-9表示apply security in this wlan first*/ switch(ret) { case SNMPD_CONNECTION_ERROR: case 0:ShowAlert(search(lwlan,"con_ebr_mult_fail")); flag=0; break; case 1:break; case -1:ShowAlert(search(lpublic,"input_para_error")); flag=0; break; case -2:ShowAlert(search(lwlan,"ebr_not_exist")); flag=0; break; case -3:ShowAlert(search(lwlan,"dis_ebr")); flag=0; break; case -4:ShowAlert(search(lwlan,"ebr_if_error")); flag=0; break; case -5:ShowAlert(search(lpublic,"sys_cmd_error")); flag=0; break; case -6:ShowAlert(search(lwlan,"spswi_iso_conflict")); flag=0; break; case -7:ShowAlert(search(lpublic,"error")); flag=0; break; case -8:{ memset(temp,0,100); strcpy(temp,search(lwlan,"ebr_id_1")); memset(ebr_id,0,10); sprintf(ebr_id,"%d",EBR_NUM-1); strcat(temp,ebr_id); strcat(temp,search(lwlan,"ebr_id_2")); ShowAlert(temp); flag=0; break; } case -9:ShowAlert(search(lwlan,"con_bind")); flag=0; break; } } /***********************ebr set bridge sameportswitch func**************************/ memset(state,0,sizeof(state)); cgiFormStringNoNewlines("sameport_switch",state,20); if(strcmp(state,"")!=0) { ret=ebr_set_bridge_sameportswitch_func(ins_para->parameter,ins_para->connection,id,state); /*返回0表示失败,返回1表示成功,返回-1表示input parameter should only be 'enable' or 'disable'*/ /*返回-2表示ebr id does not exist,返回-3表示ebr should be disable first,返回-4表示ebr if error*/ /*返回-5表示system cmd process error,返回-6表示isolation or multicast are enable,disable isolation and multicast first*/ /*返回-7表示error,返回-8示EBR ID非法*/ /*返回SNMPD_CONNECTION_ERROR表示connection error*/ switch(ret) { case SNMPD_CONNECTION_ERROR: case 0:ShowAlert(search(lwlan,"con_spswitch_fail")); flag=0; break; case 1:break; case -1:ShowAlert(search(lpublic,"input_para_error")); flag=0; break; case -2:ShowAlert(search(lwlan,"ebr_not_exist")); flag=0; break; case -3:ShowAlert(search(lwlan,"dis_ebr")); flag=0; break; case -4:ShowAlert(search(lwlan,"ebr_if_error")); flag=0; break; case -5:ShowAlert(search(lpublic,"sys_cmd_error")); flag=0; break; case -6:ShowAlert(search(lwlan,"spswi_iso_conflict2")); flag=0; break; case -7:ShowAlert(search(lpublic,"error")); flag=0; break; case -8:{ memset(temp,0,100); strcpy(temp,search(lwlan,"ebr_id_1")); memset(ebr_id,0,10); sprintf(ebr_id,"%d",EBR_NUM-1); strcat(temp,ebr_id); strcat(temp,search(lwlan,"ebr_id_2")); ShowAlert(temp); flag=0; break; } } } if(flag==1) ShowAlert(search(lpublic,"oper_succ")); }
/******************************************************************************* 函数名称 : webset_http_get_para 功能描述 : 取http参数函数封装 输入参数 : void *pstPara 原http参数 s8 *pszParaName 参数名 u32 ulGetType 提取方式 输出参数 : s8** ppszParaValue参数值 返 回 值 : u32 ERROR_FAIL 失败 -------------------------------------------------------------------------------- 最近一次修改记录 : 修改作者 : 赵奕 修改目的 : 新函数 修改日期 : 2009.8.8 *******************************************************************************/ u32 webset_http_get_para( WEBSET_HTTPD_URL_PARA *para, s8 *ci_ws_name, u32 get_type, s8** para_value) { const s8* value; int result; const char **responses; /* for pc-lint */ WEB_SEND_DEBUG_ss("webset_http_get_para checking ", ci_ws_name); if (WEBSET_HTTPD_FROM_FIRST == get_type) { /* 先试着从内部获取参数 */ value = (char*)webset_get_http_para_in(para, ci_ws_name); if (NULL == value) { /* 如果内部没有,再从cgi中获取 */ value = cgi_form_string_get_first(ci_ws_name); } } else { if (!webset_get_http_multi_exist(para, ci_ws_name)) { /* 参数不存在,先加入 */ result = cgiFormStringMultiple(ci_ws_name, (char***)&responses); if (result != cgiFormSuccess) { /* 参数在http中不存在 */ value = NULL; } else { if (ERROR_SUCCESS != webset_add_http_multi(para, ci_ws_name, responses)) { /* 加参数失败 */ value = NULL; } else { /* 参数已加入,可以取值了 */ value = webset_get_http_multi_next(para, ci_ws_name); } /* 释放参数占用的cgi空间 */ cgiStringArrayFree((char**)responses); } } else { /* 参数存在,直接取 */ value = webset_get_http_multi_next(para, ci_ws_name); } } if (NULL == value) { WEB_SEND_DEBUG_s("not found"); return ERROR_FAIL; } else { WEB_SEND_DEBUG_s("found"); *para_value = (char*)value; return ERROR_SUCCESS; } }
void Wtp_Upgrade(instance_parameter *ins_para,char *m,struct list *lpublic,struct list *lwlan) { int ret = 0,flag = 1; char count[STRING_LEN] = { 0 }; int result = cgiFormNotFound, i = 0, set_result = 1; char **responses; char temp[256] = { 0 }; memset(count,0,sizeof(count)); cgiFormStringNoNewlines("count",count,STRING_LEN); if(strcmp(count,"") != 0) { ret=wtp_set_ap_update_count_config(ins_para->parameter,ins_para->connection,count); switch(ret) { case SNMPD_CONNECTION_ERROR: case 0:ShowAlert(search(lwlan,"set_count_onetime_fail")); flag=0; break; case 1:break; case -1:ShowAlert(search(lpublic,"unknown_id_format")); flag=0; break; case -2:ShowAlert(search(lwlan,"upgrade_has_already_started")); flag=0; break; case -3:ShowAlert(search(lpublic,"error")); flag=0; break; } } result = cgiFormStringMultiple("model", &responses); if(result != cgiFormNotFound) { i = 0; while((responses[i])&&(set_result==1)) { ret=wtp_set_ap_update_base_model_config(ins_para->parameter,ins_para->connection,responses[i]); switch(ret) { case SNMPD_CONNECTION_ERROR: case 0:ShowAlert(search(lwlan,"upgrade_wtp_fail")); set_result=0; break; case 1:break; case -1:ShowAlert(search(lpublic,"malloc_error")); set_result=0; break; case -2:ShowAlert(search(lwlan,"does_not_surport_model")); set_result=0; break; case -3:ShowAlert(search(lwlan,"upgrade_is_process")); set_result=0; break; case -4:{ memset(temp,0,sizeof(temp)); strncpy(temp,search(lwlan,"model_has_been_set_ever1"),sizeof(temp)-1); strncat(temp,responses[i],sizeof(temp)-strlen(temp)-1); strncat(temp,search(lwlan,"model_has_been_set_ever2"),sizeof(temp)-strlen(temp)-1); ShowAlert(temp); set_result=0; break; } case -5:ShowAlert(search(lpublic,"error")); set_result=0; break; } i++; } cgiStringArrayFree(responses); if(set_result==0) flag=0; } if(flag==1) ShowAlert(search(lpublic,"oper_succ")); }
void down_portal_file(struct list * lpublic,struct list *lLicense,struct list *lsystem) { char **responses; int i = 0; int result = cgiFormStringMultiple("boarder", &responses); char * url = (char*)malloc(100); char * usrname = (char*)malloc(50); char * passwd = (char*)malloc(50); char * despath = (char*)malloc(50); char * sourpath = (char*)malloc(50); char * temp = (char *)malloc(100); char * alertc = (char *)malloc(50); memset(alertc,0,50); memset(url,0,100); memset(usrname,0,50); memset(passwd,0,50); memset(despath,0,50); memset(sourpath,0,50); memset(temp,0,100); char cmd[256]; int op_ret=-1; int status; ccgi_dbus_init(); cgiFormStringNoNewlines("url",url,100); cgiFormStringNoNewlines("usr",usrname,50); cgiFormStringNoNewlines("pawd",passwd,50); cgiFormStringNoNewlines("despath",despath,50); cgiFormStringNoNewlines("sourpath",sourpath,50); if((strcmp(url,"")!=0) && (strcmp(usrname,"")!=0) &&(strcmp(passwd,"")!=0)&&(strcmp(despath,"")!=0)&&(strcmp(sourpath,"")!=0)) { if(replace_url(url,"#","%23") != NULL) strcpy(temp,replace_url(url,"#","%23")); else strcpy(temp,url); memset(cmd,0,256); sprintf(cmd,"sudo ftpbatch.sh %s %s %s %s %s ",temp,usrname,passwd,sourpath,despath); LOG("%s",cmd); strcat(cmd,"> /dev/null"); status=system(cmd); op_ret=WEXITSTATUS(status); if(op_ret == 0) { if (result != cgiFormNotFound) { while (responses[i]) { LOG("%s",responses[i]); op_ret = pftp_dircpy((int)responses[i],despath,despath); i++; if(op_ret != 0) { ShowAlert(search(lpublic,"oper_fail")); } } } ShowAlert(search(lpublic,"oper_succ")); } else { ShowAlert(search(lpublic,"oper_fail")); } } else { if(strcmp(url,"")==0) ShowAlert(search(lpublic,"web_serr")); else if(strcmp(sourpath,"")==0) { memset(alertc,0,50); sprintf(alertc,"%s%s",search(lLicense,"file_remote"),search(lpublic,"param_null")); ShowAlert(alertc); } else if(strcmp(despath,"")==0) { memset(alertc,0,50); sprintf(alertc,"%s%s",search(lLicense,"file_loc"),search(lpublic,"param_null")); ShowAlert(alertc); } else if(strcmp(usrname,"")==0) ShowAlert(search(lsystem,"userna_err")); else if(strcmp(passwd,"")==0) ShowAlert(search(lsystem,"pass_err")); } free(url); free(usrname); free(passwd); free(despath); free(sourpath); free(temp); cgiStringArrayFree(responses); return; }