We are developing openwrt. The web server uses lighttpd. cgi was developed in C language. In the html form, the action is set as cgi in the form tag, and the cgi developed in C is executed. I put the script in cgi.
int main(int argc, char *argv[]){
char *form, *inStr;
long inLen;
printf("Content-type: text/html%c%c\n\n",10,10);
printf("<HTML>\n");
printf("<head>\n");
inLen = strtol(getenv("CONTENT_LENGTH"), NULL, 10) + 1;
inStr = malloc(inLen);
memset(inStr, 0, inLen);
fgets(inStr, inLen+1, stdin);
form = web_get("page", inStr, 0);
if (!strcmp(form, "reboot")) {
set_reboot(inStr);
printf("scriptype='text/javascript'>document.location.href='../index.shtml';/script>\n");
}else if (!strcmp(form,"lan"))
{
set_lan(inStr);
}
free(inStr);
printf("</head>\n");
printf("</HTML>");
return 0;
}
After running cgi in Chrome, the script will not run. This is what I see on the webpage. net.bridge.bridge-nf-call-custom = 0 Error running command OK OK OK Content-Type: text/plain; charset=utf-8
<HTML>
<head>
<script
type='text/javascript'>document.location.href='../wireless_setting.shtml';
</script>
</head>
</HTML>
I do not go to the page I want.