CGI programs can be executed in the background you silently

Button submit, often jump to the implementation of CGI interface
What method can let CGI silently in the background performing it

Started by Beatrice at November 14, 2016 - 8:26 PM

What you said is presented in the current page, plus JS script can be
When you finish the request page to submit data after the write back to jump to the page address
printf("<script>");
printf("location.href=\"/cgi-bin/timeindex.cgi\" \n");
printf("</script>");

Posted by Dolores at November 17, 2016 - 9:06 PM

Yes, this is what!
The page address how more appropriate to go, cgi-bin/timeindex.cgi this is the CGI to execute.

Posted by Beatrice at November 18, 2016 - 9:25 PM

Ajax can

Posted by Tiffany at November 29, 2016 - 10:12 PM

AJAX, She constantly refreshed, uncomfortable to go.

Posted by Matthew at December 06, 2016 - 10:53 PM


#include <stdio.h> 
#include <stdlib.h> 
#include <string.h>
#include <time.h> 
int main() 
{ 
	
 printf("Content-type: text/html\n\n") ;
 printf("<html>\n") ;
 printf("<head><center><img src=/images/maintitle-SJ.jpg border=0 width=\"100%\" height=60></center><link rel='stylesheet' type='text/css' href='/blue-style.css' /></head>\n") ;
 printf("<body bgcolor=#dee8fa link=#0000ee vlink=#0000ee background-attachment:fixed topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\" marginheight=\"0\" text=#000000 ARRAY(0x8732750)>");

 printf("<form class='ui_form' action=\"/cgi-bin/save_time.cgi\" method=get >\n") ;
 printf("<center><table border width=\"100%\" bgcolor=#dee8fa bordercolor=#000000 cellspacing=0 cellpadding=\"0\" style=\"border-collapse: collapse\">\n") ;
 printf("<tr bgcolor=#509ac7 class='maintitle'> <td align=center><font size=3><b>The system time</b></font></td></tr>\n") ;
 printf("<tr bgcolor=#dee8fa class='mainbody'> <td><table width=100%>\n") ;
 printf("<tr><td valign=top >Date</td>\n") ;
 printf("<td valign=top colspan=1 ><select name=\"date\" >\n");
 
 printf("</form><hr id='pre_footer_hr'><br>\n") ;
 printf("</body>\n") ;
 printf("</html>\n") ;
	
	return 0; 

}
The above is the timeindex.c page, its form will be submitted to the save_time.c page, is the following code
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h>
#include "funclib.h"

int main() 
{ 
	
 
 printf("Content-type: text/html\n\n") ;
 printf("<html>\n") ;
 printf("<head><center><img src=/images/maintitle-SJ.jpg border=0 width=\"100%\" height=60></center><link rel='stylesheet' type='text/css' href='/blue-style.css' /></head>\n") ;
 printf("<body bgcolor=#dee8fa link=#0000ee vlink=#0000ee style=\"font-family:Arial; font-size: 9\" background-attachment:fixed topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n") ;

 char *strTmp=NULL;
 strTmp=getenv("QUERY_STRING"); 

 char sTmp[128];
 char sTmp1[128],sTmp2[128],sTmp3[128];
 char serverdate[4],servermonth[4],serveryear[8],serverhour[4];
 char serverminute[4],serversecond[4];
 char *p= strTmp;
 int i = 0, j = 0;
 while(j<strlen(strTmp))
 {
		if(*p == '&')
			i++;
		p++;
		j++;
 }

	j=0;
	memset(sTmp,0,sizeof(sTmp));
	memset(sTmp1,0,sizeof(sTmp1));
	memset(sTmp2,0,sizeof(sTmp2));
	memset(sTmp3,0,sizeof(sTmp3));
	memset(serverdate,0,sizeof(serverdate));
	memset(servermonth,0,sizeof(servermonth));
	memset(serveryear,0,sizeof(serveryear));
	memset(serverhour,0,sizeof(serverhour));
	memset(serverminute,0,sizeof(serverminute));
	memset(serversecond,0,sizeof(serversecond));
	
	for( j = 0;j<=i;j++)
	{
		COMCfGetFld(strTmp,j,sTmp,'&');
		COMCfGetFld(sTmp,0,sTmp1,'=');
		memset(sTmp1,0,sizeof(sTmp1));
		COMCfGetFld(sTmp,1,sTmp1,'=');
		
		if(strncmp(sTmp,"date",4) == 0)
			strcpy(serverdate,sTmp1);
		else if(strncmp(sTmp,"month",5) == 0 )
			strcpy(servermonth,sTmp1);
		else if(strncmp(sTmp,"year",4) == 0)
			strcpy(serveryear,sTmp1);
		else if(strncmp(sTmp,"hour",4) == 0)
			strcpy(serverhour,sTmp1);
		else if(strncmp(sTmp,"minute",6) == 0)
			strcpy(serverminute,sTmp1);
		else if(strncmp(sTmp,"second",6) == 0)
			strcpy(serversecond,sTmp1);
		else{}

	}

 sprintf(sTmp2,"date %s%s%s%s%s" ,servermonth,serverdate,serverhour,serverminute,serveryear);
 sprintf(sTmp3,"date -s %s:%s:%s" ,serverhour,serverminute,serversecond);
 
 system(sTmp2);
 system(sTmp3);
 printf("<script>\n");
 printf("location.href=\"/cgi-bin/timeindex.cgi\"\n");
 printf("</script>\n");
 system("/usr/local/Manager/config/sbin/FssLog admin operation information to modify the system time");
 
 printf("</body>\n") ;
 printf("</html>\n") ;
	
		return 0; 

}
Save_time.c processed timeindex.c data submitted, will return to the timeindex.c page, then the effect is as if the timeindex.c page refresh, but the background has carried out your operation.

Posted by Dolores at December 13, 2016 - 11:15 PM