Exemplo n.º 1
0
int cmd_eemem( int argc, char ** argv )
{
	int ERROR = -1;
	char string[ 32 ];

	
	if ( argc == 2 )
	{
		if ( !strcmp_P( argv[1], PSTR("protect") ) )
		{
			strcpy_P( string, PSTR("ON"));
			changeConfig_P( PSTR("WRITE_PROTECT"), string );
			setprotectConfig( PROTECT );
			ERROR = 0; 
		}
		if ( !strcmp_P( argv[1], PSTR("unprotect") ) )
		{
			setprotectConfig( UNPROTECT );
			strcpy_P( string, PSTR("OFF"));
			changeConfig_P( PSTR("WRITE_PROTECT"), string );
			printf_P( PSTR("unprotectet\r\n"));
			ERROR = 0; 
		}
		if ( !strcmp_P( argv[1], PSTR("print") ) )
		{
			PrintConfig();
			ERROR = 0; 
		}
		if ( !strcmp_P( argv[1], PSTR("clean") ) )
		{
			makeConfig();
			ERROR = 0; 
		}
	}

	if ( ERROR == -1 )
		printf_P( PSTR("eemem <protect>|<unprotect> <print> <clean>\r\n"));
}
Exemplo n.º 2
0
void cgi_ntp( void * pStruct )
{
	struct HTTP_REQUEST * http_request;
	http_request = (struct HTTP_REQUEST *) pStruct;
	
	char NTPSERVER[32];
	char UTCZONE[4];

	cgi_PrintHttpheaderStart();

	// Wenn keine Variablen übergeben wurden, dann Config ausgeben,
	// wenn Variablen übergeben wurden Config ändern
	if ( http_request->argc == 0 )
	{
		readConfig_P( NTP_P, NTPSERVER );
		printf_P( PSTR(	"<form action=\"ntp.cgi\">\r"
					   	"<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">"
  						"<tr>"
					   	"<td align=\"right\">SNTP aktivieren</td>"
					    "<td><input type=\"checkbox\" name=\"NTP\" value=\"on\" " )); 
		if ( !strcmp_P( NTPSERVER, PSTR("on") ) )
						printf_P( PSTR("checked"));
		printf_P( PSTR(	"></td>"
  						"</tr>") );
		
		if( checkConfigName_P( NTP_P ) != -1 )
			readConfig_P ( NTPSERVER_P, NTPSERVER );
  		else
			strcpy_P ( NTPSERVER, PSTR("time.fu-berlin.de"));
			
		if( checkConfigName_P( UTCZONE_P ) != -1 )
			readConfig_P ( UTCZONE_P, UTCZONE );
  		else
			strcpy_P ( UTCZONE, PSTR("0"));

		printf_P( PSTR(	"<tr>"
					   	"<td align=\"right\">SNTP-Server</td>"
  						"<td><input name=\"NTPSERVER\" type=\"text\" size=\"25\" value=\"%s\" maxlength=\"25\"></td>"
  						"</tr>"
						"<tr>"
					   	"<td align=\"right\">Zeitzone</td>"
						"<td><input name=\"UTCZONE\" type=\"text\" size=\"3\" value=\"%s\" maxlength=\"3\"></td>"
  						"</tr>"
 						"<tr>"
   						"<td></td><td><input type=\"submit\" value=\" Einstellung &Uuml;bernehmen \"></td>"
  						"</tr>"
					   	"</table>"
						"</form>" ) , NTPSERVER, UTCZONE );
	}
	else
	{
		if ( PharseCheckName_P( http_request, NTP_P ) )
			changeConfig_P( NTP_P, http_request->argvalue[ PharseGetValue_P ( http_request, NTP_P ) ] );
		else
			changeConfig_P( NTP_P, "off" );	
		if ( PharseCheckName_P( http_request, NTPSERVER_P ) )
			changeConfig_P( NTPSERVER_P, http_request->argvalue[ PharseGetValue_P ( http_request, NTPSERVER_P ) ] );
		if ( PharseCheckName_P( http_request, UTCZONE_P ) )
			changeConfig_P( UTCZONE_P, http_request->argvalue[ PharseGetValue_P ( http_request, UTCZONE_P ) ] );
		
		printf_P( PSTR("Einstellungen uebernommen!\r\n"));

	}

	cgi_PrintHttpheaderEnd();
}
Exemplo n.º 3
0
/*------------------------------------------------------------------------------------------------------------*/
void cgi_twitter( void * pStruct )
{
	struct HTTP_REQUEST * http_request;
	http_request = (struct HTTP_REQUEST *) pStruct;

	printf_P( PSTR(		"<HTML>\r\n"
						"<HEAD>\r\n"
						"<TITLE>Twitter</TITLE>\r\n"
						"</HEAD>\r\n"
						" <BODY>\r\n"));

	// Wenn keine Variablen übergeben wurden, dann Config ausgeben,
	// wenn Variablen übergeben wurden Config ändern
	if ( http_request->argc == 0 )
	{
		printf_P( PSTR(	"<form action=\"twitter.cgi\">\r"
	               		"<script type=\"text/javascript\">\r\n"
		               	"function textCounter(field, countfield, maxlimit)\r\n"
						"{\r\n"
						"	if (field.value.length > maxlimit)\r\n"
						"		field.value = field.value.substring(0, maxlimit);\r\n"
						"	else\r\n"
						"		countfield.value = maxlimit - field.value.length;\r\n"
						"}\r\n"
		               	"</script>\r\n"
		               	" <table>\r"
		               	"  <tr>"
		               	"   <td valign=\"top\">Tweety-Text:</td>"
						"   <td><textarea cols=20 rows=6 style=\"WIDTH: 250px\" name=\"TWITTERMSG\" wrap=physical maxLength=\"140\" onChange=\"textCounter(this.form.TWITTERMSG,this.form.remLen,140);\" onFocus=\"textCounter(this.form.TWITTERMSG,this.form.remLen,140);\" onKeyDown=\"textCounter(this.form.TWITTERMSG,this.form.remLen,140);\" onKeyUp=\"textCounter(this.form.TWITTERMSG,this.form.remLen,140);\"></textarea>"
						"   </td>" 
						"  </tr>" 
						"  <tr>" 
						"   <td>Sie haben:</td>" 
						"   <td valign=absmiddle><input readonly type=text name=\"remLen\" size=3 maxlength=3 value=140> Zeichen &uuml;brig</td>" 
						"  </tr>" 
 						"  <tr>\r"
   						"   <td colspan=\"2\" align=\"right\"><input type=\"submit\" value=\"Tweety senden\"><br>"
  						"  </tr>\r" 
					   	" </table>\r"
		                "<a href=\"http://www.twitter.com/openmcp_foo\" target=\"_blank\">OpenMCP_foo on Twitter.</a><br>"
		               	"<a href=\"twitter.cgi?config\">Richtigen Account eingestellen.	</a>"
						"</form>" ) );
	}
	else
	{
		if ( PharseCheckName_P( http_request, PSTR("config") ) )
		{
			printf_P( PSTR( "<form action=\"twitter.cgi\" method=\"get\" accept-charset=\"ISO-8859-1\">"
					    	"<p>Accountdaten ( user:pw ) :<input name=\"userpw\" size=\"50\"></p>"
					    	"<p><input type=\"submit\" value=\"Account speichern\"></p></form>" ));
		}
		else if ( PharseCheckName_P( http_request, PSTR("userpw") ) )
		{
			changeConfig_P( PSTR("&TWITTERPW"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("userpw") ) ] );
			printf_P( PSTR("Einstellungen uebernommen!\r\n"));
		}
		else if ( PharseCheckName_P( http_request, PSTR("TWITTERMSG") ) )
		{
			char userpw[32];
			if ( readConfig_P( PSTR("&TWITTERPW"), userpw ) == -1 )
				printf_P( PSTR("Keine Accountdaten hinterlegt!"));
			else
			{
				TWITTER_sendtweet( http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("TWITTERMSG") ) ] , userpw );
				printf_P( PSTR("Tweet wurde versucht zu versenden!\r\n"));
			}
		}
	}
	
	printf_P( PSTR( " </BODY>\r\n"
					"</HTML>\r\n"
					"\r\n"));

}
Exemplo n.º 4
0
/*------------------------------------------------------------------------------------------------------------*/
void cgi_network( void * pStruct )
{
	struct HTTP_REQUEST * http_request;
	http_request = (struct HTTP_REQUEST *) pStruct;
	
	unsigned char IP[32];

/*	printf_P( PSTR(		"<HTML>\r\n"
						"<HEAD>\r\n"
						"<TITLE>network</TITLE>\r\n"
						"</HEAD>\r\n"
						" <BODY>\r\n"));
*/
	cgi_PrintHttpheaderStart();

	if ( http_request->argc == 0 )
	{
					   
		printf_P( PSTR( "<pre>\r\n") );
#ifdef TELNETSERVER
		TELNET_runcmdextern_P( PSTR("ifconfig") );
		TELNET_runcmdextern_P( PSTR("stats") );
#endif		
		printf_P( PSTR( "</pre>\r\n") );
	}
	else if( PharseCheckName_P( http_request, PSTR("config") ) )
	{	
		
		printf_P( PSTR(	"<form action=\"network.cgi\">\r"
					   	" <table border=\"0\" cellpadding=\"5\" cellspacing=\"0\">" ));
#ifdef DHCP
		readConfig_P( PSTR("DHCP"), IP );
  		printf_P( PSTR( "  <tr>\r"
					   	"   <td align=\"right\">DHCP aktivieren</td>"
					    "   <td><input type=\"checkbox\" name=\"DHCP\" value=\"on\" " )); 
		if ( !strcmp_P( IP, PSTR("on") ) )
						printf_P( PSTR("checked"));
		printf_P( PSTR(	"></td>\r"
  						"  </tr>\r") );
#endif
		if ( readConfig_P ( PSTR("IP"), IP ) != 1 )
			iptostr ( myIP, IP );
  		printf_P( PSTR(	"  <tr>\r"
					   	"   <td align=\"right\">IP-Adresse</td>"
  						"   <td><input name=\"IP\" type=\"text\" size=\"15\" value=\"%s\" maxlength=\"15\"></td>"
  						"  </tr>\r") , IP );
		if ( readConfig_P ( PSTR("MASK"), IP ) != 1 )
			iptostr ( Netmask, IP );		
  		printf_P( PSTR(	"  <tr>\r"
					   	"   <td align=\"right\">Netzwerkmaske</td>"
  						"   <td><input name=\"MASK\" type=\"text\" size=\"15\" value=\"%s\" maxlength=\"15\"></td>"
  						"  </tr>\r") , IP );
		if ( readConfig_P ( PSTR("GATE"), IP ) != 1 )
			iptostr ( Gateway, IP );		
  		printf_P( PSTR(	"  <tr>\r"
					   	"   <td align=\"right\">Gateway</td>"
						"   <td><input name=\"GATE\" type=\"text\" size=\"15\" value=\"%s\" maxlength=\"15\"></td>"
  						"  </tr>\r") , IP );
#ifdef DNS
		if ( readConfig_P ( PSTR("DNS"), IP ) != 1 )
			iptostr ( DNSserver, IP );		
		printf_P( PSTR(	"  <tr>\r"
					   	"   <td align=\"right\">DNS-Server</td>"
						"   <td><input name=\"DNS\" type=\"text\" size=\"15\" value=\"%s\" maxlength=\"15\"></td>"
  						"  </tr>\r" ), IP );
#endif
		readConfig_P( PSTR("ETH_FLDX"), IP );
  		printf_P( PSTR( "  <tr>\r"
					   	"   <td align=\"right\">Fullduplex aktivieren</td>"
					    "   <td><input type=\"checkbox\" name=\"ETH_FLDX\" value=\"on\" " )); 
		if ( !strcmp_P( IP, PSTR("on") ) )
						printf_P( PSTR("checked"));
		printf_P( PSTR(	"></td>\r"
  						"  </tr>\r") );

		if ( readConfig_P ( PSTR("MAC"), IP ) != 1 )
			mactostr( mymac, IP );
  		printf_P( PSTR(	"  <tr>\r"
					   	"   <td align=\"right\">Hardware-MAC</td>"
						"   <td><input name=\"MAC\" type=\"text\" size=\"17\" value=\"%s\" maxlength=\"17\"></td>"
  						"  </tr>\r"
		  				"  <tr>\r"
   						"   <td></td><td><input type=\"submit\" value=\" Einstellung &Uuml;bernehmen \"></td>"
  						"  </tr>\r"
					   	" </table>\r"
						"</form>") , IP );
	}
	else
	{
#ifdef DHCP
		if ( PharseCheckName_P( http_request, PSTR("DHCP") ) )
			changeConfig_P( PSTR("DHCP"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("DHCP") ) ] );
		else
			changeConfig_P( PSTR("DHCP"), "off" );
#endif
		if ( PharseCheckName_P( http_request, PSTR("IP") ) )
			changeConfig_P( PSTR("IP"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("IP") ) ] );
		if ( PharseCheckName_P( http_request, PSTR("MASK") ) )
			changeConfig_P( PSTR("MASK"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("MASK") ) ] );
		if ( PharseCheckName_P( http_request, PSTR("GATE") ) )
			changeConfig_P( PSTR("GATE"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("GATE") ) ] );
		#ifdef DNS
		if ( PharseCheckName_P( http_request, PSTR("DNS") ) )
			changeConfig_P( PSTR("DNS"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("DNS") ) ] );
		#endif
		if ( PharseCheckName_P( http_request, PSTR("MAC") ) )
			changeConfig_P( PSTR("MAC"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("MAC") ) ] );
		if ( PharseCheckName_P( http_request, PSTR("ETH_FLDX") ) )
			changeConfig_P( PSTR("ETH_FLDX"), http_request->argvalue[ PharseGetValue_P ( http_request, PSTR("ETH_FLDX") ) ] );
		else
			changeConfig_P( PSTR("ETH_FLDX"), "off" );
		printf_P( PSTR("Einstellungen uebernommen!\r\n"));
	}
	
	cgi_PrintHttpheaderEnd();
	
/*	printf_P( PSTR( " </BODY>\r\n"
					"</HTML>\r\n"
					"\r\n"), IP);
*/
}